node-sass node-gyp 에러로 인해 npm install이 안된다면...!

회사에서 m1 맥북을 새로 받아서 기뻤던 나... 하지만 재택근무 중에 갑자기 기존 맥을 반납했어야 해서 migration을 못하고 기존 맥을 밀어버린 뒤, 새로운 맥을 새로 세팅했어야 했다.

그말인 즉슨 node js도 다시 깔아야한다는 말...^^

어쩔 수 없이 처음에 배웠던 것 처럼 LTS 버전(2022년 2월 현재 16버전)을 install한 뒤, 회사 repo를 클론하고 npm install을 하려고 했으나 아래와 같은 에러를 마주하게 되었다.

npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/binding/src/binding.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/somi/Desktop/Slid/slid_web/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/somi/Desktop/Slid/slid_web/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/somi/Desktop/Slid/slid_web/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

이에 node-sass, node-gyp를 삭제, 재설치하라는 사람들의 조언에 따라 그렇게 했지만, 무슨 수를 써도 결과적으로 해결되지 않았다.

그런데 package.json을 보니 node-sass가 4.14.1로 묶여 있었고, node-sass 14버전은 node 16에서 지원되지 않음을 확인했다.

같은 맥북을 받은 동료분께 물어보니 그분은 migration을 해서 14버전의 node가 설치되어 있었고, 이 경우 npm start도 잘 되고 있었다.

그래서 침착하게 노드를 14로 내려주기로 했다...!

  1. 노드 삭제는 여기를 참고하여 진행했다.

  2. 내가 원하는 노드 버전 설치는 이곳에서 했다.

  3. 터미널에서 node -v를 입력해주고 원하는 노드의 버전이 설치되었는지 확인한다.

  4. 이제 잘 될거다...!

nvm으로 노드의 버전을 스위칭해서 사용하는 방법도 있는데, 왜인지 m1에서는 node 14버전을 설치하려고 하면 자꾸 에러가 나서 나는 위의 방법으로 설치했다.

아무튼 오랜시간 시달렸는데, 잘 되어서 다행;;

혹시 잘못된 정보가 있다면 코멘트 달아주세요!

좋은 웹페이지 즐겨찾기