当前位置: 首页 > 工具软件 > Fes.js > 使用案例 >

node.js-express报错:'express' 不是内部或外部命令,也不是可运行的程序 的解决方案

法浩壤
2023-12-01
问题:
C:\Users\Dai_YuanDa>express --version
'express' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

原因:版本问题

解决方案:
方式一:执行 npm install -g express-generator
方式二:执行 npm install -g express@3.5.0 后
C:\Users\Dai_YuanDa>npm install -g express@3.5.0
npm WARN deprecated connect@2.14.1: connect 2.x series is deprecated
npm WARN deprecated static-favicon@1.0.0: use serve-favicon module
C:\Users\Dai_YuanDa\AppData\Roaming\npm\express -> C:\Users\Dai_YuanDa\AppData\R
oaming\npm\node_modules\express\bin\express
- depd@1.1.1 node_modules\express\node_modules\depd
- destroy@1.0.4 node_modules\express\node_modules\destroy
- ee-first@1.1.1 node_modules\express\node_modules\ee-first
- encodeurl@1.0.1 node_modules\express\node_modules\encodeurl
- escape-html@1.0.3 node_modules\express\node_modules\escape-html
- etag@1.8.1 node_modules\express\node_modules\etag
- forwarded@0.1.1 node_modules\express\node_modules\forwarded
- ipaddr.js@1.4.0 node_modules\express\node_modules\ipaddr.js
- media-typer@0.3.0 node_modules\express\node_modules\media-typer
- mime-db@1.30.0 node_modules\express\node_modules\mime-db
- mime-types@2.1.17 node_modules\express\node_modules\mime-types
- ms@2.0.0 node_modules\express\node_modules\ms
- on-finished@2.3.0 node_modules\express\node_modules\on-finished
- parseurl@1.3.2 node_modules\express\node_modules\parseurl
- setprototypeof@1.0.3 node_modules\express\node_modules\setprototypeof
- statuses@1.3.1 node_modules\express\node_modules\statuses
- http-errors@1.6.2 node_modules\express\node_modules\http-errors
- unpipe@1.0.0 node_modules\express\node_modules\unpipe
- accepts@1.3.4 node_modules\express\node_modules\accepts
- array-flatten@1.1.1 node_modules\express\node_modules\array-flatten
- content-disposition@0.5.2 node_modules\express\node_modules\content-dispositio
n
- content-type@1.0.4 node_modules\express\node_modules\content-type
- finalhandler@1.0.4 node_modules\express\node_modules\finalhandler
- path-to-regexp@0.1.7 node_modules\express\node_modules\path-to-regexp
- proxy-addr@1.1.5 node_modules\express\node_modules\proxy-addr
- type-is@1.6.15 node_modules\express\node_modules\type-is
- vary@1.1.1 node_modules\express\node_modules\vary
C:\Users\Dai_YuanDa\AppData\Roaming\npm
`-- express@3.5.0
+-- buffer-crc32@0.2.1
+-- commander@1.3.2
| `-- keypress@0.1.0
+-- connect@2.14.1
| +-- basic-auth-connect@1.0.0
| +-- bytes@0.2.1
| +-- compression@1.0.0
| | +-- compressible@1.0.0
| | `-- negotiator@0.3.0
| +-- connect-timeout@1.0.0
| +-- cookie-parser@1.0.1
| | `-- cookie@0.1.0
| +-- csurf@1.0.0
| | `-- uid2@0.0.3
| +-- errorhandler@1.0.0
| +-- express-session@1.0.2
| | +-- cookie@0.1.0
| | `-- debug@0.7.4
| +-- method-override@1.0.0
| +-- morgan@1.0.0
| +-- multiparty@2.2.0
| | +-- readable-stream@1.1.14
| | | +-- core-util-is@1.0.2
| | | +-- isarray@0.0.1
| | | `-- string_decoder@0.10.31
| | `-- stream-counter@0.2.0
| +-- pause@0.0.1
| +-- qs@0.6.6
| +-- raw-body@1.1.3
| +-- response-time@1.0.0
| +-- serve-index@1.0.1
| | +-- batch@0.5.0
| | `-- negotiator@0.4.2
| +-- serve-static@1.0.2
| +-- static-favicon@1.0.0
| `-- vhost@1.0.0
+-- cookie@0.1.1
+-- cookie-signature@1.0.3
+-- debug@0.8.1
+-- fresh@0.2.2
+-- merge-descriptors@0.0.2
+-- methods@0.1.0
+-- mkdirp@0.3.5
+-- range-parser@1.0.0
`-- send@0.2.0
`-- mime@1.2.11

2.再执行命令 express -v
C:\Users\Dai_YuanDa>express - v

create : -
create : -/package.json
create : -/app.js
create : -/public
create : -/routes
create : -/routes/index.js
create : -/routes/user.js
create : -/views
create : -/views/layout.jade
create : -/views/index.jade
create : -/public/javascripts
create : -/public/stylesheets
create : -/public/stylesheets/style.css
create : -/public/images

install dependencies:
$ cd - && npm install

run the app:
$ node app
 类似资料: