node-sass version 6.0.1 is incompatible with ^4.0.0 와 dependency tree 에러[해결법]

Sming·2021년 9월 10일
1

이슈 모음집

목록 보기
3/3

이번에 알아볼 이슈는 node sass version 6.0.1 is incompatible with ^4.0.0 이 에러이다.
Create-react-app 을 npm start 할시 자주 볼수 있을것이다.

이것은 말그대로 현재 package.json 에 설치되있는 node-sass 를 4.0.0 에 맞추라는 얘기다.

npm i node-sass@4.14.1

node-sass 를 4.14.1 로 다운그레이드 한뒤 실행 시킬시 이 에러를 없앨수 있다.
하지만 4.14.1 을 설치할때 에러로 설치를 못하는 경우가 있는데 그럴경우에는

npm uninstall node-sass
npm install node-sass
npm install sass-loader@latest

를 이용하여 sass-loadernode-sass의 최신 버전을 재 설치해준다.

그런다음에 node_modules와 npm 이용자의 경우 package-lock.json, yarn 이용자의 경우 yarn.lock 파일을 지워준다.

rm -rf node_modules

삭제할때는 이 명령어를 이용하여 삭제하는것을 추천한다.

그런뒤 다시 npm install 혹은 yarn 명령어를 쳐서 다시 node_modulespackage-lock.json 을 설치한뒤 npm start를 하여 실행 해보자.

두번째 에러

여기서 에러가 뜨며 바로 안되는 경우가 있을것이다.

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "webpack": "4.44.2"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:


/*중략*/

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if C:\Users\82104\workspace\react-udemy\e-commerce\e-commerce\lesson-3\crwn-clothing\client\node_modules\we
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls webpack in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed webpack.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

이 에러는 dependency tree 에러 로서 현재 npm의 최신 버전은 7.x.x 인데 npm 은 7버전으로 업그레이드 하면서 peer dependencies 가 있을 경우 아예 설치를 막아버리게 하였다.

그래서 이것을 해결하기 위해서는 다시 node_modules와 package-lock.json 을 지운뒤 이제 npm i 로 다시 설치하는것이 아니라
2가지 방법으로 실행을 시켜보면 된다.

 npm install --force // 충돌을 우회하는 코드
 npm install --legacy-peer-deps//충돌을 무시하는 경우

먼저 --force 로 해보고 안될 경우 --legacy-peer-deps 를 해보도록 하자.

참고

혹시 저것도 안된다면 전역위치에 .env 파일을 만든후 SKIP_PREFLIGHT_CHECK=true 를 붙혀넣고 저장시키자

profile
딩구르르

0개의 댓글