npm 에러들 해결 방법

이윤희·2025년 1월 2일

React/Next 일기

목록 보기
7/52

npm error code ENOENT

2025.01.02 리액트 개발환경 구축 오류 2

배경: 새로운 프로젝트 만들려고 npx create-react-app 했는데 안 됨

npm error code ENOENT
npm error syscall open
npm error path D:\다운로드\공부\shop\package.json
npm error errno -4058
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'D:\다운로드\공부\shop\package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: C:\Users\sister\AppData\Local\npm-cache\_logs\2025-01-02T09_37_11_996Z-debug-0.log



난 폴더에 아무것도 안 만든 상태였어서 (package.json도 없음) 여러가지 시도해 봤는데 (npm install도 해보고...) 계속 같은 오류가 떴다.

결과적으로는 이 글 참조하여 문제 해결...

npm -g install create-react-app

한 줄 알았는데!!!

또다른 오류가 떴다;;


npm error code ERESOLVE

PS D:\다운로드\공부\shop> npx create-react-app shop

Creating a new React app in D:\다운로드\공부\shop\shop.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


added 1322 packages in 1m

266 packages are looking for funding
  run `npm fund` for details

Initialized a git repository.

Installing template dependencies using npm...
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: shop@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\sister\AppData\Local\npm-cache\_logs\2025-01-02T09_49_28_589Z-eresolve-report.txt
npm error A complete log of this run can be found in: C:\Users\sister\AppData\Local\npm-cache\_logs\2025-01-02T09_49_28_589Z-debug-0.log

react 버전이 높아서 호환이 안된단다.

react를 18버전으로 깔아주면 된다고.

cd shop # 그 폴더 안에 들어가서 해야함
npm install react@18 react-dom@18

그리고 나서 npm start 하니 구동 되는것 같길래 휴~ 했더니 또 오류가 ㅡㅡ



Module not found: Error: Can't resolve 'web-vitals'

PS D:\다운로드\공부\shop\shop> npm start

> shop@0.1.0 start   
> react-scripts start
Starting the development server...

One of your dependencies, babel-preset-react-app, is importing the      
"@babel/plugin-proposal-private-property-in-object" package without     
declaring it in its dependencies. This is currently working because     
"@babel/plugin-proposal-private-property-in-object" is already in your  
node_modules folder for unrelated reasons, but it may break at any time.

Failed to compile.

Module not found: Error: Can't resolve 'web-vitals' in 'D:\다운로드\공부\shop\shop\src'
ERROR in ./src/reportWebVitals.js 5:4-24
Module not found: Error: Can't resolve 'web-vitals' in 'D:\다운로드\공부\shop\shop\src'

webpack compiled with 1 error

webvitals 라는 모듈을 깔아주면 된다는 것 같다...

npm install web-vitals

설치했더니 정상적으로 컴파일된다.


Compiled successfully!

You can now view shop in the browser.

  http://localhost:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

webpack compiled successfully

0개의 댓글