Express-Generator(NodeJS)的'npm start'

我是NodeJS的新手,我试图用快速和快速生成器开始。 我用命令安装了express:

C:\project>npm install -g express 

然后我安装了express-generator模块:

 C:\project>npm install -g express-generator 

然后我为该项目创build一个文件夹并安装de依赖项:

 C:\project\express> nodetest1 C:\project\nodetest1>npm install 

一切工作正常,但是当我尝试启动服务器,出现问题与命令:

 C:\project\nodetest1>npm start 

看来,服务启动,但它一开始就closures,结果:

 > nodetest1@0.0.0 start C:\project\nodetest1 > node ./bin/www C:\project\nodetest1> 

当我尝试打开localhost:3000时,它不起作用。 我在网上search,我还没有find一个解决scheme,有人可以指导我如何解决这个问题?

谢谢。

更新1:

重新安装node.js并按照下面提出的步骤,现在我得到一个错误:

 C:\wamp\www\mynewapp>npm start > mynewapp@0.0.0 start C:\wamp\www\mynewapp > node ./bin/www npm ERR! mynewapp@0.0.0 start: `node ./bin/www` npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the mynewapp@0.0.0 start script. npm ERR! This is most likely a problem with the mynewapp 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 mynewapp npm ERR! There is likely additional logging output above. npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" npm ERR! cwd C:\wamp\www\mynewapp npm ERR! node -v v0.10.32 npm ERR! npm -v 1.4.28 npm ERR! syscall spawn npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! mynewapp@0.0.0 start: `node ./bin/www` npm ERR! Exit status -1 npm ERR! npm ERR! Failed at the mynewapp@0.0.0 start script. npm ERR! This is most likely a problem with the mynewapp 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 mynewapp npm ERR! There is likely additional logging output above. npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" npm ERR! cwd C:\wamp\www\mynewapp npm ERR! node -v v0.10.32 npm ERR! npm -v 1.4.28 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! C:\wamp\www\mynewapp\npm-debug.log npm ERR! not ok code 0 C:\wamp\www\mynewapp> 

你需要检查你的package.json npm start在做什么。 它应该有命令来启动你的应用程序,它应该有一个看起来像这样的一部分:

 "scripts": { "start": "node app.js" }, 

app.js应该是由生成器创build的,但是考虑到您描述的步骤,似乎您忘记了生成应用程序。 尝试这个:

 express mynewapp cd mynewapp npm install npm start 

你可以很容易地解决这个问题。 转到“packages.json”文件,然后更改开始

 "scripts": { "start": "node ./bin/www" 

}

并使其“开始”:“节点app.js” 。 然后运行命令npm start ,该项目不会工作。 现在回到原来的位置,重新开始启动:“ Express ./bin/www” ,它是Express的默认值,然后运行命令npm start。 它为我工作。