git hub로 레파지토리에 있던 리액트 파일을 가져올 때
package.json 파일과 node_modules 파일이 있는지 확인해보아야 한다.
이 두 파일이 없다면 에러가 발생하게 된다.
- package.json 파일이 없는 상태로 npm install 하면 밑에 처럼 이런 오류가 발생하게 된다.
D:\react git\react_study_alone>npm install
npm error code ENOENT
npm error syscall open
npm error path D:\react git\react_study_alone\package.json
npm error errno -4058
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'D:\react git\react_study_alone\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\owner\AppData\Local\npm-cache\_logs\2024-09-29T11_08_35_325Z-debug-0.log
또한
node_modules 파일이 없다면 이런 오류가 발생하게 된다.
D:\react git\react_study_alone>npm run start
> react_project1@0.1.0 start
> react-scripts start
'react-scripts'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.
node_modules 파일이 없다면 npm_install을 해서 받아오면 된다.
(나는 다른 파일의 node_modules 폴더를 복사해서 붙여넣기 해줌)
- 의존성 설치 확인
package.json 파일이 있는지 확인하고, 해당 파일에 react-scripts가 포함되어 있는지 확인하고 react-scripts가 없다면 밑의 코드 입력
npm install react-scripts
- npm 캐시 클리어 하는 방법
npm cache clean --force
rm -rf node_modules
npm install
'리액트 > 이론' 카테고리의 다른 글
리액트 앱 성능 개선하기 (리액트 확장 프로그램 추가) (1) | 2024.11.07 |
---|---|
리액트 수행시 visual studio 확장팩 리스트 (0) | 2024.09.29 |
JSX Key 속성 (1) | 2024.09.18 |
전개 연산자 (0) | 2024.09.18 |
리액트 - React Hooks (1) | 2024.09.15 |