windows中使用node express 4.12创建的web应用,使用npm start启动报错?

创建应用:

$ express -c stylus myapp

然后用

npm install && npm start

启动失败,报错:

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v0.12.1
npm ERR! npm  v2.5.1
npm ERR! file C:\Windows\system32\cmd.exe;
npm ERR! path C:\Windows\system32\cmd.exe;
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn C:\Windows\system32\cmd.exe;
npm ERR! myapp@0.0.0 start: `node ./bin/www`
npm ERR! spawn C:\Windows\system32\cmd.exe; ENOENT
npm ERR!
npm ERR! Failed at the myapp@0.0.0 start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the myapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./bin/www
npm ERR! You can get their info via:
npm ERR!     npm owner ls myapp
npm ERR! There is likely additional logging output above.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v0.12.1
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! myapp@0.0.0 start: `node ./bin/www`
npm ERR! Exit status -4058
npm ERR!
npm ERR! Failed at the myapp@0.0.0 start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the myapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./bin/www
npm ERR! You can get their info via:
npm ERR!     npm owner ls myapp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\nodeJS\expressStudy\myapp\npm-debug.log

但是使用

node bin/www

则成功运行,请问这是为什么?是不是因为windows cmd没有ls命令?

//package.json
{
  "name": "myapp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.12.0",
    "cookie-parser": "~1.3.4",
    "debug": "~2.1.1",
    "express": "~4.12.2",
    "jade": "~1.9.2",
    "morgan": "~1.5.1",
    "serve-favicon": "~2.2.0",
    "stylus": "0.42.3"
  }
}
阅读 10k
3 个回答

你看看package.json里面有没有 start命令先

从报错看:不能执行.node ./bin/www. 但是可以执行 node bin/www 显然./ 是bash风格

两个建议:
1.升级NPM

 npm -v
 npm update 

2.npm 只是包管理器,可以拆解 npm install && npm start 运行,正如你正确的做法.
By the way,
一般运行nodejs的项目,都是通过node ***.js来运行的,所谓的
npm start grunt serve grunt server都是接管了这类指令

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Microsoft
子站问答
访问
宣传栏