我是 NodeJS 的新手,我正在尝试从 express 和 express-generator 开始。我已经使用以下命令安装了 express:
C:\project>npm install -g express
然后我安装了 express-generator 模块:
C:\project>npm install -g express-generator
然后我为项目创建一个文件夹并安装 de 依赖项:
C:\project\express> nodetest1
C:\project\nodetest1>npm install
那里一切正常,但是当我尝试使用以下命令启动服务器时出现问题:
C:\project\nodetest1>npm start
该服务似乎启动了,但它一启动就关闭了,结果:
> nodetest1@0.0.0 start C:\project\nodetest1
> node ./bin/www
C:\project\nodetest1>
当我尝试打开localhost:3000时,它不起作用。我在网上搜索了,我还没有找到解决方案,有人可以指导我如何解决这个问题吗?
谢谢你。
更新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>