Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Archives
Today
Total
관리 메뉴

성빈

npm start package.json파일 없음 에러, start 스크립트 에러 본문

React

npm start package.json파일 없음 에러, start 스크립트 에러

성빈나 2024. 10. 12. 19:42

 

1. package.json 파일이 없는 경우

 

npm start 명령을 입력했지만, 아래와 같은 오류가 떴다.

club> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\...\WebPrograming TeamProject\club\package.json
npm ERR! errno -4058
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\Users\...\WebPrograming TeamProject\club\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:\Users\clala\AppData\Local\npm-cache\_logs\2024-10-12T08_25_52_763Z-debug-0.log

 

  • package.json 파일 확인: 폴더에 package.json 파일이 있는지 확인해보자. 이 파일이 없으면 npm 명령을 실행할 수 없다.
  • package.json 파일 생성 (없을 경우): 폴더에 package.json 파일이 없으면 npm init 명령을 실행해서 파일을 생성한다. 기본 설정을 완료한 후 다시 npm install을 실행해서 의존성을 설치하고, 이후 npm start를 입력해본다.
    npm init -> npm install - npm start

 

 

2. start 스크립트 에러

아래 에러메세지는 현재 package.json 파일의 scripts 섹션에 start 스크립트가 정의되어 있지 않아 발생하는 문제이다.  

 

package.json 파일을 보았을 때, start에 대한 정의가 되어있지 않음을 확인할 수 있었다.

 

아래와 같이 start 정의 부분을 추가하여 주면, 문제가 해결됨을 확인할 수 있었다.

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "react-scripts start" // 이부분 추가
  },