繁体   English   中英

npm start 和 npm run build 因 npm ERR 失败! 代码生命周期

[英]npm start and npm run build fail with npm ERR! code ELIFECYCLE

我已经有这个问题 3 天了。 我曾经偶尔收到此错误,它会在执行一些故障排除命令后才开始工作,现在 npm start 根本不起作用,并且我不断收到此错误。

主机详情:

Ubuntu server 18.04 LTS
Node v8.10.0
npm 6.10.2

我已按此顺序尝试了以下操作:

rm -rf node_modules
rm package-lock.json
npm install -g npm
npm install
npm start
sudo npm start

然后:

npm install create-react-app
npm install react-scripts
node node_modules/react-scripts/scripts/start.js

还尝试删除整个文件夹,创建目录并再次从 github 中提取。 只是为了尝试chown ubuntu project_folder

没有任何工作。

该应用程序是使用 create-react-app 创建的,它在我的台式机和笔记本电脑上运行良好。

Starting the development server...

The build failed because the process exited too early. This probably means the system ran out of memory or someone called `k
ill -9` on the process.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! REDACTED@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the REDACTED@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/2019-08-05T14_02_01_500Z-debug.log

来自 /home/ubuntu/.npm/_logs/2019-08-05T14_02_01_500Z-debug.log 的数据:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.10.2
3 info using node@v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle REDACTED@0.1.0~prestart: REDACTED@0.1.0
6 info lifecycle REDACTED@0.1.0~start: REDACTED@0.1.0
7 verbose lifecycle REDACTED@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle REDACTED@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/hom
e/ubuntu/code/bf_dev/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ga
mes:/snap/bin
9 verbose lifecycle REDACTED@0.1.0~start: CWD: /home/ubuntu/code/bf_dev
10 silly lifecycle REDACTED@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle REDACTED@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle REDACTED@0.1.0~start: Failed to exec start script
13 verbose stack Error: REDACTED@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:326:16
)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55
:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid REDACTED@0.1.0
15 verbose cwd /home/ubuntu/code/bf_dev
16 verbose Linux 4.15.0-1044-aws
17 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v8.10.0
19 verbose npm  v6.10.2
20 error code ELIFECYCLE
21 error errno 1
22 error REDACTED@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the REDACTED@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 [ 1, true ]

任何帮助是极大的赞赏。

我多次遇到此错误。 npm install create-react-app ,使用命令create-react-app检查 create-react-app 是否已安装。 它将显示尚未安装 create-react-app,因为您没有在项目所在的文件夹中安装 create-react-app。 你只需要在正确的目录中安装 create-react-app 或者您可以使用以下命令全局安装它

npm install -g create-react-app

如果不想全局安装,请转到项目所在的文件夹,然后在该文件夹中安装 create-react-app。

基本上,您收到此错误是因为 create-react-app 未安装在您的目录中。 这应该可以解决您的问题。

如果这没有帮助,您可以执行以下操作:

注意:您的机器上需要有 Node >= 8.10 和 npm >= 5.6。 转到所需的文件夹。 然后,

ngx create-react-app my-app
cd my-app
npm start

这是在 create react app 的官方文档中,所以,这应该可以工作。

感谢所有人的回复。 看起来像用户错误。

在此线程之后更新了 nodejs: 如何更新 Node.js?

并且项目加载得很好,我想 Arch 处于软件的最前沿,而 ubuntu 存储库落后于我。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM