npm start 由于 node-api@ELIFECYCLE 而失败

npm start fails because of node-api@ ELIFECYCLE

我在启动 node.js 服务器时遇到问题。服务器应用程序在另一个系统上进行了测试并且运行良好。 错误日志说 node-api@ 有问题,但我找不到任何解决方案。

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@2.9.1
3 info using node@v0.12.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart node-api@
6 info start node-api@
7 verbose unsafe-perm in lifecycle true
8 info node-api@ Failed to exec start script
9 verbose stack Error: node-api@ start: `node server.js`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9 verbose stack     at EventEmitter.emit (events.js:110:17)
9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
9 verbose stack     at ChildProcess.emit (events.js:110:17)
9 verbose stack     at maybeClose (child_process.js:1015:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
10 verbose pkgid node-api@
11 verbose cwd /Volumes/HDD/Users/…/app/db
12 error Darwin 14.3.0
13 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
14 error node v0.12.3
15 error npm  v2.9.1
16 error code ELIFECYCLE
17 error node-api@ start: `node server.js`
17 error Exit status 1
18 error Failed at the node-api@ start script 'node server.js'.
18 error This is most likely a problem with the node-api package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     node server.js
18 error You can get their info via:
18 error     npm owner ls node-api
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

我的安装有什么问题,我该如何解决?

您可以在此处尝试两件事:

  1. 确保您 运行 与另一个系统 运行 完美地运行使用相同版本的 Node。您可以通过在您的终端和它正在运行的终端上输入以下内容来测试它:node -v。如果它们不同,请升级(或降级)您的安装。
  2. 从当前计算机的项目根目录中删除 node_modules 目录,然后 运行 和 npm install 以确保编译的二进制文件与您的操作系统兼容。

我进入此页面寻找类似错误日志的解决方案。

我的问题是我已经在后台启动了 webpack 开发服务器,但在让 Node 再次启动它之前忘记杀死它。

尝试查找进程 PID(输出的第二列)

ps -u [your user name]

然后发送SIGINT信号(2)给PID为

的进程

kill -2 [PID]

希望这对访问此页面的其他人有所帮助。

当我的代码中出现编译错误时,我遇到了同样的错误。我用过 npm start

我遇到了同样的问题。对于我的情况,我是在添加以下行之后发生的 在我的 package.json 文件中。

"scripts": {
    "start": "node index.js"
}

删除启动脚本后它解决了。

现在我是 运行 我的服务器 node index.js

我不会声称完全理解解决方案。我认为这与导航时记录的错误地址有关 node_modules,或者可能是我的 watchman 版本已过时或损坏。

我通过重新安装 watchman 和 deleting/recreating node_modulespackage-lock.json 文件解决了这个问题。

npm cache clean --force

rm -rf node_modules

rm -rf package-lock.json

brew uninstall watchman

npm r -g watchman

npm install watchman

npm install

npm start

这是一个很长的链条和一个非常不确定的答案;但在被困了很长时间之后,这就是让我克服它的原因。

祝你好运。

我重新安装了 webpack,它成功了

"npm i --save-dev webpack@1.14.0"

清除系统缓存和运行终端中的命令

npm cache clean --force

然后

npm start

我有过类似的事情,我的错误是我没有访问这些文件夹的权限,所以我使用的是 Manjaro,我 运行 我的应用程序

sudo npm start

还有那个