简体   繁体   English

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

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

I have had this issue for 3 days now.我已经有这个问题 3 天了。 I used to get this error occasionally and it would just start working after a few troubleshooting commands, now npm start is not working at all and I keep getting this error.我曾经偶尔收到此错误,它会在执行一些故障排除命令后才开始工作,现在 npm start 根本不起作用,并且我不断收到此错误。

Host Details:主机详情:

Ubuntu server 18.04 LTS
Node v8.10.0
npm 6.10.2

I have tried the following in this order:我已按此顺序尝试了以下操作:

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

Then:然后:

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

Also tried deleting the entire folder, making the directory and pulling from github again.还尝试删除整个文件夹,创建目录并再次从 github 中提取。 Just to try it chown ubuntu project_folder只是为了尝试chown ubuntu project_folder

Nothing is working.没有任何工作。

The app was created using create-react-app and it works fine on my desktop and my laptop.该应用程序是使用 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

Data from /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 ]

Any help is greatly appreciated.任何帮助是极大的赞赏。

I have had this error many times.我多次遇到此错误。 After npm install create-react-app , check if create-react-app has been installed with the command create-react-app .npm install create-react-app ,使用命令create-react-app检查 create-react-app 是否已安装。 It will show you that create-react-app has not been installed because you are not installing create-react-app on the folder where your project is.它将显示尚未安装 create-react-app,因为您没有在项目所在的文件夹中安装 create-react-app。 You just have to install create-react-app in right directory .你只需要在正确的目录中安装 create-react-app Or you can install it globally with或者您可以使用以下命令全局安装它

npm install -g create-react-app npm install -g create-react-app

If you don't want to install it globally, go to the folder where your project is and then install create-react-app in that folder.如果不想全局安装,请转到项目所在的文件夹,然后在该文件夹中安装 create-react-app。

Basically, you are getting this error because create-react-app is not installed on your directory.基本上,您收到此错误是因为 create-react-app 未安装在您的目录中。 This should fix your problem.这应该可以解决您的问题。

If this does not help, you can do the following:如果这没有帮助,您可以执行以下操作:

Note: You'll need to have Node >= 8.10 and npm >= 5.6 on your machine.注意:您的机器上需要有 Node >= 8.10 和 npm >= 5.6。 Go to a desired folder.转到所需的文件夹。 Then,然后,

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

This is in the official documentation of create react app, So, this should work.这是在 create react app 的官方文档中,所以,这应该可以工作。

Thanks everyone for the replies.感谢所有人的回复。 Looks like user error.看起来像用户错误。

updated nodejs following this thread: How do I update Node.js?在此线程之后更新了 nodejs: 如何更新 Node.js?

and the project loads just fine, I guess with Arch being on the bleeding edge of software and the ubuntu repos being behind got to me.并且项目加载得很好,我想 Arch 处于软件的最前沿,而 ubuntu 存储库落后于我。

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

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