簡體   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