npm start failing: Error: start: `react-scripts start`
npm start failing: Error: start: `react-scripts start`
同事用 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、uninstall/reinstall node 等
找到这个帖子 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)
折腾了两天终于弄明白了,当前的app是一个子子项目,路径是这样的:main-project/sub-project1/src/main/sub-sub-project1。但是在 sub-project1 文件夹中有一堆来自另一个同事过去工作的剩余节点文件(package.json 等),显然我有 运行 “npm install” 并生成了 node_modules/ 文件夹,因为它被忽略了,我从来没有意识到这一点。这个 node_modules/ 文件夹是导致节点命令混淆的原因,当它们在 sub-sub-project1 文件夹中 运行 时,另一个 node_modules/ 存在。
总而言之,不要以这种线性分层方式进行多个节点项目,这可能会导致节点命令混乱。
同事用 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、uninstall/reinstall node 等
找到这个帖子 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)
折腾了两天终于弄明白了,当前的app是一个子子项目,路径是这样的:main-project/sub-project1/src/main/sub-sub-project1。但是在 sub-project1 文件夹中有一堆来自另一个同事过去工作的剩余节点文件(package.json 等),显然我有 运行 “npm install” 并生成了 node_modules/ 文件夹,因为它被忽略了,我从来没有意识到这一点。这个 node_modules/ 文件夹是导致节点命令混淆的原因,当它们在 sub-sub-project1 文件夹中 运行 时,另一个 node_modules/ 存在。
总而言之,不要以这种线性分层方式进行多个节点项目,这可能会导致节点命令混乱。