node.js 由于 node-api@ELIFECYCLE,npm start 失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30239752/
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:45:59  来源:igfitidea点击:

npm start fails because of node-api@ ELIFECYCLE

node.jsmacosnpm

提问by AppleCoderXY

I have a problem starting a node.js server. The server app was tested on another system and worked perfectly. The error log says that something is wrong with the node-api@ but I was not able to find any solution.

我在启动 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 [email protected]
3 info using [email protected]
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 ]

What is wrong with my installation and how can I solve this?

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

回答by Tom Hallam

Two things you can try here:

您可以在这里尝试两件事:

  1. Ensure that you are running the same version of Node as the other system where it was seen running perfectly. You can test this by entering the following on your terminal and the terminal it was working on: node -v. If they're different, look to upgrade (or indeed downgrade) your installation.
  2. Delete the node_modulesdirectory from the project root on your current computer, then run an npm installto ensure that the binaries that were compiled are compatible with your operating system.
  1. 确保您运行的 Node 版本与其他系统运行的 Node 版本相同。您可以通过在您的终端和它正在处理的终端上输入以下内容来测试:node -v. 如果它们不同,请升级(或确实降级)您的安装。
  2. node_modules从当前计算机上的项目根目录中删除该目录,然后运行npm install以确保编译的二进制文件与您的操作系统兼容。

回答by Hyman

I got to this page looking for a solution to a similar error log.

我到这个页面寻找类似错误日志的解决方案。

My problem was that I had started the webpack dev server in the background and had forgotten to kill it before asking Node to start it up again.

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

Try to find the process PID (second column of output)

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

ps -u [your user name]

ps -u [your user name]

Then send the SIGINT signal (2) to the process with the PID

然后将SIGINT信号(2)发送给PID的进程

kill -2 [PID]

kill -2 [PID]

Hope this helps others that come to this page.

希望这可以帮助到此页面的其他人。

回答by reza.cse08

I faced same problem. For my case, I it occurred after adding following line in my package.jsonfile.

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

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

After remove the start scripts it solved.

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

Now I am running my server by node index.js

现在我通过节点 index.js运行我的服务器

回答by Adam Durey

I wouldn't claim to entirely understand the solution. I think it had something to do with either incorrect addresses recorded to navigate node_modules, or it may have been my version of watchman was outdated or corrupted.

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

I fixed the issue by reinstalling watchman and deleting/recreating the node_modulesand package-lock.jsonfiles.

我通过重新安装 watchman 并删除/重新创建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

It's a long chain and a pretty uncertain answer; but after being stuck for a long time this is what got me past it.

这是一个很长的链条,一个相当不确定的答案;但在被困了很长时间之后,这就是让我过去的原因。

Good luck.

祝你好运。

回答by Celso Xavier Luz

I reinstalled the webpack and it worked

我重新安装了 webpack 并且它起作用了

?

?

"npm i --save-dev [email protected]"

“npm i --save-dev [email protected]

回答by Shubhanshu Gupta

Clear the system cache and run the command in the terminal

清除系统缓存并在终端中运行命令

npm cache clean --force

then

然后

npm start

回答by Josue Reyes

I had something like that, and my mistake was that i do not have permission of access to the folders, so i was using Manjaro and i run my app with

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

sudo npm start

须藤 npm 开始

and that

然后

回答by manikanta

I got this same error when I have compilation errors in my code. I've used npm start

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