평소처럼 react-app의 터미널에서 yarn start명령어를 입력했는데
error Command failed with exit code 127.
오류코드가 떴었다.
기존의 해결법은 npm update
혹은 npm install
이었다.
하지만 계속 오류 코드가 발생했고, 로그 경로를 따라 들어가봤다.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jeongsohee/.npm/_logs/2023-07-12T15_20_38_840Z-debug-0.log
이게 그 문제의 로그...
0 verbose cli /usr/local/bin/node /usr/local/bin/npm
1 info using npm@9.5.1
2 info using node@v18.16.1
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 2ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/Users/jeongsohee/Desktop/redux-basic-todo-1/.npmrc Completed in 0ms
10 timing config:load:project Completed in 4ms
11 timing config:load:file:/Users/jeongsohee/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 11ms
17 timing npm:load:configload Completed in 11ms
18 timing npm:load:mkdirpcache Completed in 1ms
19 timing npm:load:mkdirplogs Completed in 0ms
20 verbose title npm install
21 verbose argv "install"
22 timing npm:load:setTitle Completed in 19ms
23 timing config:load:flatten Completed in 3ms
24 timing npm:load:display Completed in 4ms
25 verbose logfile logs-max:10 dir:/Users/jeongsohee/.npm/_logs/2023-07-12T15_20_38_840Z-
26 verbose logfile /Users/jeongsohee/.npm/_logs/2023-07-12T15_20_38_840Z-debug-0.log
27 timing npm:load:logFile Completed in 7ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 44ms
31 timing arborist:ctor Completed in 1ms
32 silly logfile start cleaning logs, removing 1 files
33 silly logfile done cleaning log files
34 timing idealTree:init Completed in 963ms
35 timing idealTree:userRequests Completed in 0ms
36 silly idealTree buildDeps
37 timing idealTree:#root Completed in 1ms
38 silly fetch manifest typescript@^3.2.1 || ^4
39 verbose shrinkwrap failed to load node_modules/.package-lock.json out of date, updated: node_modules
40 http fetch GET 200 https://registry.npmjs.org/typescript 1213ms (cache revalidated)
41 silly placeDep ROOT typescript@4.9.5 REPLACE for: react-scripts@5.0.1 want: ^3.2.1 || ^4
42 timing idealTree:node_modules/react-scripts Completed in 1310ms
43 silly fetch manifest react@^0.14.9 || ^15.3.0 || ^16.0.0
44 http fetch GET 200 https://registry.npmjs.org/react 171ms (cache revalidated)
45 silly fetch manifest react-redux@^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
46 http fetch GET 200 https://registry.npmjs.org/react-redux 47ms (cache revalidated)
47 timing idealTree Completed in 2537ms
48 timing command:install Completed in 2546ms
49 verbose stack Error: could not resolve
49 verbose stack at PlaceDep.failPeerConflict (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:503:25)
49 verbose stack at new PlaceDep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:157:21)
49 verbose stack at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:943:31
49 verbose stack at Array.map (<anonymous>)
49 verbose stack at [buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:943:8)
49 verbose stack at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:207:7)
49 verbose stack at async Promise.all (index 1)
49 verbose stack at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:159:5)
49 verbose stack at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:146:5)
49 verbose stack at async module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:134:5)
50 verbose cwd /Users/jeongsohee/Desktop/redux-basic-todo-1
51 verbose Darwin 21.6.0
52 verbose node v18.16.1
53 verbose npm v9.5.1
54 error code ERESOLVE
55 error ERESOLVE could not resolve
56 error
57 error While resolving: [1mredux-devtools[22m@[1m3.7.0[22m
57 error Found: [1mreact[22m@[1m18.2.0[22m[2m[22m
57 error [2mnode_modules/react[22m
57 error [1mreact[22m@"[1m^18.2.0[22m" from the root project
57 error [35mpeer[39m [1mreact[22m@"[1m^18.0.0[22m" from [1m@testing-library/react[22m@[1m13.4.0[22m[2m[22m
57 error [2mnode_modules/@testing-library/react[22m
57 error [1m@testing-library/react[22m@"[1m^13.0.0[22m" from the root project
57 error 7 more (react-dom, react-redux, react-router, react-router-dom, ...)
57 error
57 error Could not resolve dependency:
57 error [35mpeer[39m [1mreact[22m@"[1m^0.14.9 || ^15.3.0 || ^16.0.0[22m" from [1mredux-devtools[22m@[1m3.7.0[22m[2m[22m
57 error [2mnode_modules/redux-devtools[22m
57 error [33mdev[39m [1mredux-devtools[22m@"[1m3.7.0[22m" from the root project
57 error
57 error Conflicting peer dependency: [1mreact[22m@[1m16.14.0[22m[2m[22m
57 error [2mnode_modules/react[22m
57 error [35mpeer[39m [1mreact[22m@"[1m^0.14.9 || ^15.3.0 || ^16.0.0[22m" from [1mredux-devtools[22m@[1m3.7.0[22m[2m[22m
57 error [2mnode_modules/redux-devtools[22m
57 error [33mdev[39m [1mredux-devtools[22m@"[1m3.7.0[22m" from the root project
57 error
57 error Fix the upstream dependency conflict, or retry
57 error this command with --force or --legacy-peer-deps
57 error to accept an incorrect (and potentially broken) dependency resolution.
58 error
58 error
58 error For a full report see:
58 error /Users/jeongsohee/.npm/_logs/2023-07-12T15_20_38_840Z-eresolve-report.txt
59 verbose exit 1
60 timing npm Completed in 2626ms
61 verbose unfinished npm timer reify 1689175238916
62 verbose unfinished npm timer reify:loadTrees 1689175238919
63 verbose unfinished npm timer idealTree:buildDeps 1689175239884
64 verbose unfinished npm timer idealTree:node_modules/redux-devtools 1689175241195
65 verbose code 1
66 error A complete log of this run can be found in:
66 error /Users/jeongsohee/.npm/_logs/2023-07-12T15_20_38_840Z-debug-0.log
이렇게 많은;;
Error: could not resolve
at PlaceDep.failPeerConflict (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:503:25)
...
Conflicting peer dependency: react@16.14.0
...
Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.
npm install 명령에 --force 플래그를 추가하여 설치를 강제로 진행해보세요. 예를 들면 npm install react-scripts --force와 같이 명령을 실행합니다. 그러나 이렇게 하면 충돌이 있는 의존성을 무시하고 설치되므로, 프로젝트가 올바르게 작동하는지 확인해야 합니다.
npm install 명령에 --legacy-peer-deps 플래그를 추가하여 설치를 진행해보세요. 예를 들면 npm install react-scripts --legacy-peer-deps와 같이 명령을 실행합니다. 이 플래그는 npm 7 이전 버전과의 호환성을 유지하면서 의존성 충돌을 해결하는 데 도움이 될 수 있습니다.
위의 두 가지 방법을 시도해보고 문제가 해결되는지 확인해보세요. 그러나 가능하면 의존성 충돌을 해결하여 프로젝트에 올바른 의존성 트리가 구성되도록 하는 것이 좋습니다. 이를 위해서는 package.json 파일의 의존성 버전을 업데이트하거나, 충돌이 발생하는 다른 의존성을 제거하거나 대체해야 할 수도 있습니다.
npm install react-scripts --legacy-peer-deps
나는 이 방법으로 해결했다.. 🥹