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

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

原因:版本问题

解决方案:
方式一:执行 npm install -g express-generator
方式二:执行 npm install -g [email protected]
C:\Users\Dai_YuanDa>npm install -g [email protected]
npm WARN deprecated [email protected]: connect 2.x series is deprecated
npm WARN deprecated [email protected]: 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
- [email protected] node_modules\express\node_modules\depd
- [email protected] node_modules\express\node_modules\destroy
- [email protected] node_modules\express\node_modules\ee-first
- [email protected] node_modules\express\node_modules\encodeurl
- [email protected] node_modules\express\node_modules\escape-html
- [email protected] node_modules\express\node_modules\etag
- [email protected] node_modules\express\node_modules\forwarded
- [email protected] node_modules\express\node_modules\ipaddr.js
- [email protected] node_modules\express\node_modules\media-typer
- [email protected] node_modules\express\node_modules\mime-db
- [email protected] node_modules\express\node_modules\mime-types
- [email protected] node_modules\express\node_modules\ms
- [email protected] node_modules\express\node_modules\on-finished
- [email protected] node_modules\express\node_modules\parseurl
- [email protected] node_modules\express\node_modules\setprototypeof
- [email protected] node_modules\express\node_modules\statuses
- [email protected] node_modules\express\node_modules\http-errors
- [email protected] node_modules\express\node_modules\unpipe
- [email protected] node_modules\express\node_modules\accepts
- [email protected] node_modules\express\node_modules\array-flatten
- [email protected] node_modules\express\node_modules\content-dispositio
n
- [email protected] node_modules\express\node_modules\content-type
- [email protected] node_modules\express\node_modules\finalhandler
- [email protected] node_modules\express\node_modules\path-to-regexp
- [email protected] node_modules\express\node_modules\proxy-addr
- [email protected] node_modules\express\node_modules\type-is
- [email protected] node_modules\express\node_modules\vary
C:\Users\Dai_YuanDa\AppData\Roaming\npm
| | | +-- [email protected]
| | | +-- [email protected]
| | | `-- [email protected]

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

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