DRF로 구축한 백엔드 API 서버와 React로 구축한 프론트단을 연결해보기 위해 공부하면서 책 저자님의 깃허브에서 리액트 프로젝트를 clone해서 사용하려고 했다.
npm install로 package-json module을 업데이트 해준 뒤, npm start를 해주면 에러 메세지가 길게 나오면서 npm build failed with error code 1 라는 오류 메세지가 나왔다.
최신버전 깔았을시 이런 에러가 떠요 - 코딩애플 온라인 강좌
PS E:\react\shop> yarn add node-sass@4.14.1 yarn add v1.22.10 [1/4] Resolving packages... warning node-sass > node-gyp > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 [2/4] Fetching packages... info fsevent
codingapple.com
위의 링크와 같은 내용이었고, 해결 방법도 위 글을 참고하였다.
오류 메세지를 잘 확인해보니 node-sass라는 것의 버전이 현재 로컬의 nodejs버전과 맞지 않아서 생기는 오류 같았다.
내 로컬에 설치한 nodejs의 버전은 아래와 같았다.
아래 링크에 가보면 node버전 별로 호환되는 node-sass의 버전이 명시되어 있다.
https://www.npmjs.com/package/node-sass
node-sass
Wrapper around libsass. Latest version: 8.0.0, last published: a month ago. Start using node-sass in your project by running `npm i node-sass`. There are 12475 other projects in the npm registry using node-sass.
www.npmjs.com
node-sass의 버전이 4.14? 정도 였기 때문에 node 버전에 맞게 node-sass를 삭제한 뒤 8.0 버전으로 업데이트 해주었다.
그 다음 프로젝트 폴더 내에 node_modules 폴더, yarn.lock, package-lock.json 을 다 삭제해주고 npm install로 node_modules 폴더를 재설치 해주었다.
(npm install에서 에러가 나서 npm install --verbose와 npm audit fix --force 도 해주었다.)
리액트 프로젝트의 package.json 에서 node-sass의 버전을 확인해보면 8.0 버전으로 업그레이드가 된 것을 확인해 볼 수 있다.
이 후 npm start를 해보니 잘 실행되었다.
'React' 카테고리의 다른 글
[ React ] 리액트에서 API KEY 숨기기 (.env) (0) | 2023.01.03 |
---|---|
[ React ] 리액트에서 state를 사용하여 페이지네이션(Pagination) 직접 구현하기 + setState 비동기 처리 문제 해결 (0) | 2022.12.31 |
[ React ] img태그의 src 속성에 props로 require() 전달 시 "Cannot find module" 에러 (0) | 2022.12.26 |