🔥𝗔𝗰𝘁𝗶𝘃𝗶𝘁𝘆/🌊𝗧𝗜𝗟

[오류처리] node-sass 설치오류, version 문제 해결

안오늘 2021. 9. 17. 21:36

에러 상황

1. yarn add node-sass로 설치했는데 6.0.1 버전은 지원하지 않고 4.0.0이나 5.0.0을 써야한다고 나왔다. 

2. yarn remove node-sass했으나 명령이 듣지 않았다. package.json이 아니다? 이런식으로 나왔다.

3. 검색후 나온 방법인 yarn add node-sass@5.0.0 을 쳤더니 아래와 같은 에러가 나왔다. (너무 길어서 아래 부분만 올렸다)

1 error generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/ahntoday/Desktop/Frontend/react-shopping-mall/shop/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/usr/local/Cellar/node/16.6.1/bin/node" "/Users/ahntoday/Desktop/Frontend/react-shopping-mall/shop/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/ahntoday/Desktop/Frontend/react-shopping-mall/shop/node_modules/node-sass
gyp ERR! node -v v16.6.1

 

해결방법

나는 node 버전이 16.6.1이었고, 다음과 같은 방법으로 해결했다.

1. yarn add node-sass로 최신버전(6버전) 설치

2. 프로젝트 폴더 내에 node_modules 폴더, yarn.lock, package-lock.json 삭제

3. 터미널에서 yarn install로 node_modules 폴더 재설치

터미널 끄고 다시 yarn start 하면 잘 나온다!