同事用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,它似乎表明重装node可以解决这个问题,但它对我不起作用。
后续行动:通过额外的手动步骤完全删除节点,例如这里建议的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)发布于 2021-02-12 04:52:21
经过两天的努力终于弄清楚了,目前的应用是一个子项目,它的路径是这样的: main-project/sub-project1/src/main/sub-sub-project1.但是有一堆剩余的节点文件(package.json等)。在另一个同事以前的工作中的子项目1文件夹中,显然我已经运行了"npm install“并在那里生成了一个node_modules/文件夹,因为它是gitignored,我从来没有意识到这一点。当node命令在sub-sub-project1文件夹中运行时,node_modules/文件夹是造成节点命令混乱的原因,其中存在另一个node_modules/。
总而言之,不要以这种线性分层的方式拥有多个节点项目,这可能会导致节点命令混乱。
https://stackoverflow.com/questions/66143698
复制相似问题