npm start和npm run build失败,npm ERR!代码ELIFECYCLE

时间:2019-08-05 15:39:20

标签: reactjs npm create-react-app

我已经有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 ]

非常感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

我多次遇到此错误。 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应用的官方文档中,因此,这应该可以工作。

答案 1 :(得分:0)

感谢大家的答复。看起来像用户错误。

在以下线程之后更新了nodejs:How do I update Node.js?

项目加载得很好,我想Arch处于软件的最前沿,而后面的ubuntu仓库就来了。