반응형
안녕하세요.
오늘 새로운 프로젝트를 세팅 중에 오류가 발생하여 해결하였던 내용을 공유해보려고 합니다😊
문제 발생
기존에 있던 프로젝트를 가져와서 사용을 하게 되었는데, yarn install 명령어 실행 시 오류가 발생하였습니다.
yarn install
/Users/user/Documents/workspace/.../node_modules/node-sass: Command failed.
...
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/user/Documents/workspace/.../node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (node:events:390:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.3.0
gyp ERR! command "/usr/local/bin/node" "/Users/user/Documents/workspace/.../node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/user/Documents/workspace/.../node_modules/node-sass
gyp ERR! node -v v16.13.2
내용을 보니 node-sass 모듈과 node 버전 차이로 인한 오류인 듯 보였습니다.
원인 확인
구글에 내용을 검색해보니, package.json에 설정된 node-sass 버전이 로컬에 설치된 node 버전과 맞지 않아서 발생하는 오류였습니다.
Node 버전 별 지원되는 node-sass 버전은 아래 표에서 확인할 수 있습니다.
NodeJS | Supported node-sass version | Node Module |
Node 17 | 7.0+ | 102 |
Node 16 | 6.0+ | 93 |
Node 15 | 5.0+, <7.0 | 88 |
Node 14 | 4.14+ | 83 |
Node 13 | 4.13+, <5.0 | 79 |
Node 12 | 4.12+ | 72 |
Node 11 | 4.10+, <5.0 | 67 |
Node 10 | 4.9+, <6.0 | 64 |
Node 8 | 4.5.3+, <5.0 | 57 |
Node <8 | <5.0 | <57 |
제 로컬에 설치된 node 버전은 비교적 최신버전(v16.3.2)이었으나 node-sass 버전은 훨씬 하위 버전(v4.7.2)이었습니다.
node -v
v16.13.2
"node-sass": "^4.7.2",
해결 방법
방법은 node-sass를 최신 버전으로 재 설치해주는 것입니다.
아래와 같이 명령어를 실행해줍니다.
yarn add node-sass
yarn add 버전은 가장 최신 버전의 패키지를 설치해줍니다.
그럼 package.json에 아래와 같이 최신 버전으로 변경이 된 것을 확인할 수 있습니다.
"node-sass": "^7.0.1",
그리고 다시 yarn install을 실행하니 정상적으로 설치가 완료되었습니다.
Reference
- https://stackoverflow.com/questions/60394291/error-node-modules-node-sass-command-failed
- https://classic.yarnpkg.com/lang/en/docs/cli/add/
- https://www.npmjs.com/package/node-sass
반응형
'node.js' 카테고리의 다른 글
[nodejs] package.json 파일에서 dependencies와 devDependencies 차이점 (0) | 2024.07.10 |
---|