웹공부/React

[에러해결] npx create-react-app . 명령어가 실행되지 않음

Rabet 2025. 1. 7. 08:00

 

첫번째로 npm에 install 문제가 생겼다.

npx create-react-app .

npm init react-app my-app
Need to install the following packages:
create-react-app@5.0.1
Ok to proceed? (y) y

 

오류를 보니 package.json에서 React 19.x를 사용하려고 시도하지만, @testing-library/reactReact 18.x를 요구하고 있어서 호환되지 않는다.

Installing template dependencies using npm...
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: react_start@0.1.0
npm error Found: react@19.0.0
npm error node_modules/react
npm error   react@"^19.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^18.0.0" from @testing-library/react@13.4.0
npm error node_modules/@testing-library/react
npm error   @testing-library/react@"^13.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error C:\Users\User\AppData\Local\npm-cache\_logs\2025-01-06T22_32_12_181Z-eresolve-report.txt     
npm error A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2025-01-06T22_32_12_181Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed

 

react를 18버전으로 변경하고 

npm install react@18 react-dom@18

 

다시 설치를 시작한다. 

npm install

 

 

그리고 다시 시작했더니!

npm start
Compiled with problems:
×
ERROR in ./src/reportWebVitals.js 5:4-24
Module not found: Error: Can't resolve 'web-vitals' in

또 오류.. web-vitals가 없는 것 같았다.

npm install web-vitals
npm i web-vitals

 

다시 npm start를 실행하면,

해결되었다!

 

다음 코드를 통해 build를 실행 시킬 수 있다. 

npm run build
npm run preview
npm run dev