【发布时间】:2021-02-12 04:52:21
【问题描述】:
同事使用 create-react-app 创建了一个项目,它可以在他的计算机上运行。我克隆,运行 npm install,然后 npm start,得到以下失败错误:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/local/Cellar/node/15.8.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v15.8.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle candyjar@0.1.0~prestart: candyjar@0.1.0
6 info lifecycle candyjar@0.1.0~start: candyjar@0.1.0
7 verbose lifecycle candyjar@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle candyjar@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/dzhai/Documents/workplace/tcoe-candyjar/apis/src/main/app/node_modules/.bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/usr/local/opt/gnu-getopt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dzhai/Library/Python/3.7/bin:/Library/Apple/usr/bin:/opt/apache-maven/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dzhai/Library/Python/3.7/bin:/Library/Apple/usr/bin
9 verbose lifecycle candyjar@0.1.0~start: CWD: /Users/dzhai/Documents/workplace/tcoe-candyjar/apis/src/main/app
10 silly lifecycle candyjar@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle candyjar@0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle candyjar@0.1.0~start: Failed to exec start script
13 verbose stack Error: candyjar@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:332:16)
13 verbose stack at EventEmitter.emit (node:events:378:20)
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 ChildProcess.emit (node:events:378:20)
13 verbose stack at maybeClose (node:internal/child_process:1067:16)
13 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
14 verbose pkgid candyjar@0.1.0
15 verbose cwd /Users/dzhai/Documents/workplace/tcoe-candyjar/apis/src/main/app
16 verbose Darwin 19.6.0
17 verbose argv "/usr/local/Cellar/node/15.8.0/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v15.8.0
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error candyjar@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the candyjar@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 ]
有人可以帮忙吗?谢谢
PS:我已经尝试删除 node_modules 并重新运行 npm install、卸载/重新安装节点等。
发现这个线程https://github.com/facebook/create-react-app/issues/9594 似乎表明重新安装节点可以解决问题,但它对我不起作用。
跟进:通过额外的手动步骤完全删除节点,例如,这里建议https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/,然后重复该过程,然后得到稍微不同的错误日志:
23 verbose stack Error: command failed
23 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
23 verbose stack at ChildProcess.emit (node:events:378:20)
23 verbose stack at maybeClose (node:internal/child_process:1067:16)
23 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
【问题讨论】:
-
用
BROWSER=none启动是不是也一样? -
抱歉,新手,您的意思是运行“npm start BROWSER=none”吗,我刚刚这样做了,它返回的结果相同。
-
更像
BROWSER=none npm start或任何当前启动 CRA 应用程序的方式——这只是一个健全性检查。有几件事会导致启动失败;您可能必须搜索并开始插入它们,但要开始检查所有内容的版本并确保它们对齐(例如,要启动 NodeJS 和 CRA)。
标签: node.js npm create-react-app