node.js - `npm start` 给出生命周期错误并以状态 9 退出

标签 node.js reactjs linux ubuntu npm

到目前为止,我已经看过类似的问题,例如 this issuethis one .解决方案似乎是:

rm package-lock.json
npm cache clean --force
npm install
npm start

我已经尝试了这些步骤,但总是出现同样的错误:

> client@0.1.0 start /home/ubuntu/react/client
> react-scripts --openssl-legacy-provider start

/usr/bin/node: bad option: --openssl-legacy-provider
npm ERR! code ELIFECYCLE
npm ERR! errno 9
npm ERR! client@0.1.0 start: `react-scripts --openssl-legacy-provider start`
npm ERR! Exit status 9
npm ERR!
npm ERR! Failed at the client@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2021-12-20T09_28_07_369Z-debug.log

/home/ubuntu/.npm/_logs/2021-12-20T09_28_07_369Z-debug.log 的输出是:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.14.8
3 info using node@v12.18.2
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle client@0.1.0~prestart: client@0.1.0
6 info lifecycle client@0.1.0~start: client@0.1.0
7 verbose lifecycle client@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle client@0.1.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ubuntu/react/client/node_modules/.bin:/home/ubuntu/.virtualenvs/react/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ubuntu/go/bin
9 verbose lifecycle client@0.1.0~start: CWD: /home/ubuntu/react/client
10 silly lifecycle client@0.1.0~start: Args: [ '-c', 'react-scripts --openssl-legacy-provider start' ]
11 silly lifecycle client@0.1.0~start: Returned: code: 9  signal: null
12 info lifecycle client@0.1.0~start: Failed to exec start script
13 verbose stack Error: client@0.1.0 start: `react-scripts --openssl-legacy-provider start`
13 verbose stack Exit status 9
13 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid client@0.1.0
15 verbose cwd /home/ubuntu/react/client
16 verbose Linux 5.8.0-63-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v12.18.2
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 9
22 error client@0.1.0 start: `react-scripts --openssl-legacy-provider start`
22 error Exit status 9
23 error Failed at the client@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 9, true ]

我看到的所有帖子的退出状态似乎都是 1,而我的是 9。可能是什么问题?据我了解,退出状态 9 表示该进程正在被系统终止,但我不知道为什么或如何找出答案。

最佳答案

如果出于某种原因(例如,没有管理员权限或其他原因)在用户机器上无法进行 Node 升级,那么我发现这可以解决问题: 更改参数在命令中出现的位置,因此在 package.json 中而不是:

"start": "react-scripts --openssl-legacy-provider start"

这样做:

"start": "react-scripts start --openssl-legacy-provider"

来源:https://github.com/coreui/coreui-free-react-admin-template/issues/336

关于node.js - `npm start` 给出生命周期错误并以状态 9 退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70419935/

相关文章:

javascript - React 获取 JSX 中的特定元素

linux - C linux 中的 Makefile 错误

linux - 使用 CP2102 的 TTL 串行 USB 转换器时出现问题

linux - 连续打印标准输出并写入文件

arrays - 使用 mongoose 将对象添加到数组

node.js - 如何防止 session 变量发生更改?

javascript - React 是否在 setState 回调中绑定(bind)了它?

javascript (reactJS) 访问子数组中的值的最佳方法

node.js - 在单独的文件中对 Mongoose 模型进行单元测试会导致问题(使用 Mockgoose 和 Lab)

javascript - 在网站上运行 node.js 但不在本地主机上运行