npm 开始在 node.js 中出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27794932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:16:59  来源:igfitidea点击:

npm start giving error in node.js

node.jsnpm

提问by kow

i am totally new to node.js and mongodb. I am using the following link: http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/This procedure worked very fine and got the exact same results. But all of a sudden "npm start" stopped working. I uninstalled every thing and trying to re-install from step 1 given in this tutorial. when i give the command "npm install -g express" i am not getting any list of http 304's and GETS!! . As i ignore and continue the procedure, i give the command npm start , but it does not work. the error displayed is shown below C:\project\nodetest1>npm start

我对 node.js 和 mongodb 完全陌生。我正在使用以下链接:http: //cwbuecheler.com/web/tutorials/2013/node-express-mongo/这个过程工作得很好,得到了完全相同的结果。但突然间“npm start”停止工作。我卸载了所有东西并尝试从本教程中给出的第 1 步重新安装。当我发出“npm install -g express”命令时,我没有得到任何 http 304 和 GETS 列表!!. 当我忽略并继续该过程时,我给出了命令 npm start ,但它不起作用。显示的错误如下所示 C:\project\nodetest1>npm start

  > [email protected] start C:\project\nodetest1
  > node ./bin/www


   npm ERR! [email protected] start: `node ./bin/www`
   npm ERR! spawn ENOENT
   npm ERR!
   npm ERR! Failed at the [email protected] start script.
   npm ERR! This is most likely a problem with the nodetest1 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 nodetest1
   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:\project\nodetest1
  npm ERR! node -v v0.10.33
  npm ERR! npm -v 1.4.28
  npm ERR! syscall spawn
  npm ERR! code ELIFECYCLE
  npm ERR! errno ENOENT
  npm ERR! [email protected] start: `node ./bin/www`
  npm ERR! Exit status -1
  npm ERR!
  npm ERR! Failed at the [email protected] start script.
  npm ERR! This is most likely a problem with the nodetest1 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 nodetest1
  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:\ProgramFiles\nodejs\node_modules\npm\bin\npm-cli.js" "start"
  npm ERR! cwd C:\project\nodetest1
  npm ERR! node -v v0.10.33
  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:\project\nodetest1\npm-debug.log
  npm ERR! not ok code 0

Please help . Thanks in advance.

请帮忙 。提前致谢。

回答by Toni S.

The error suggests that the ./bin/www directory is not found. Paths specified with a dot are relative to the current directory, so your current directory has to be C:/project/nodetest1 for npm startto work in this case.

该错误表明未找到 ./bin/www 目录。用点指定的路径是相对于当前目录的,所以你的当前目录必须是 C:/project/nodetest1npm start才能在这种情况下工作。

回答by Sam Mikes

There are several issues here.

这里有几个问题。

First, you should upgrade to a newer npm, as the npmthat ships with even the latest version of nodeis out of date. To upgrade npmon Windows, follow the instructions here: https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows

首先,您应该升级到更新的npm,因为npm即使是最新版本的node也已过时。要npm在 Windows 上升级,请按照此处的说明进行操作:https: //github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows

Second, you may need to do some more troubleshooting on your own to find the problem. npm startjust follows the instructions in the package.json. The package.json is telling npmthat startmeans "run node ./bin/www".

其次,您可能需要自己进行更多故障排除才能找到问题。 npm start只需按照package.json. package.json 告诉npmstart意味着“运行节点 ./bin/www”。

What happens when you run that same script from the command line?

当您从命令行运行相同的脚本时会发生什么?

cd C:\project\nodetest1 node ./bin/www

cd C:\project\nodetest1 节点 ./bin/www

Does the file 'bin/www' exist? Is node installed and in your path? These are the issues that you will have to troubleshoot.

文件“bin/www”是否存在?节点是否已安装并在您的路径中?这些是您必须解决的问题。

回答by randomSampling

Delete the node_modules folder. Run npm installAnd then, re-run your command npm start

删除 node_modules 文件夹。运行npm install然后,重新运行您的命令npm start

回答by Selvam Annamalai

The package.json is telling npm that start means "run node ./bin/www".**but packege.json predefined staring script is npm run serve **

package.json 告诉 npm start 的意思是“运行节点 ./bin/www”。**但 packege.json 预定义的凝视脚本是 npm run serve **

please try this one.

请试试这个。

npm run serve

npm 运行服务

"start": "concurrently \"npm run build:watch\" \"npm run serve\""

"start": "concurrently \"npm run build:watch\" \"npm run serve\""