npm ERR! code 1, node-pre-gyp, node-sass 에러 해결

jellyjw·2024년 2월 18일
0

code 1, node-pre-gyp 에러

새 프로젝트를 들어가게 되면서 모듈을 설치하는 중에, 계속해서 모듈 설치가 되지 않고 같은 에러를 만나게 되었다.
프로젝트 실행 자체가 안되는 상황이라 에러메세지를 참고해서 구글링하고, 동료분들 도움을 받아 여러가지 방법을 시도해 봤다.

시도해본 방법

  • 파이썬 2, 3 버전 설치 및 환경변수 설정
  • node 버전 변경(14 ~ 18) - 해당 프로젝트 진행중인 동료와 동일하게 맞춰봄
  • windows-build-tools 설치 등..

계속해서 뜨던 에러메세지 일부분이다.

npm ERR! code 1
npm ERR! path C:\Users\dev\Desktop\irontrain\ngstudy-admin-real\node_modules\grpc
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build --library=static_library
npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\dev\AppData\Roaming\nvm\v16.16.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build 
--library=static_library --module=C:\Users\dev\Desktop\irontrain\ngstudy-admin-real\node_modules\grpc\src\node\extension_binary\node-v93-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\dev\Desktop\irontrain\ngstudy-admin-real\node_modules\grpc\src\node\extension_binary\node-v93-win32-x64-unknown --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93 --python=/path/to/executable/python --msvs_version=2017' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@0.14.0
npm ERR! node-pre-gyp info using node@16.16.0 | win32 | x64
npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download
npm ERR! node-pre-gyp info check checked for "C:\Users\dev\Desktop\irontrain\ngstudy-admin-real\node_modules\grpc\src\node\extension_binary\node-v93-win32-x64-unknown\grpc_node.node" (not 
found)
npm ERR! node-pre-gyp http GET https://node-precompiled-binaries.grpc.io/grpc/v1.24.2/node-v93-win32-x64-unknown.tar.gz
npm ERR! node-pre-gyp http 404 https://node-precompiled-binaries.grpc.io/grpc/v1.24.2/node-v93-win32-x64-unknown.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.24.2/node-v93-win32-x64-unknown.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for grpc@1.24.2 and node@16.16.0 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 404 status code downloading tarball https://node-precompiled-binaries.grpc.io/grpc/v1.24.2/node-v93-win32-x64-unknown.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.16.0 | win32 | x64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.16.0 | win32 | x64

....

해결

기존 모듈 설치가 안될 때 주로 node-sass 때문에 에러나던 상황이 많았기 때문에 혹시나 해서 찾아보니, 우리 프로젝트의 node-sass는 4.9.0 이었다. 해당 버전에선 node 16을 지원하지 않는다고 나와있어 버전을 더 낮춰서 시도해보기로 했다!

nvm install 12.15.0
nvm use 12.15.0

이러고 npm i 했을때 모듈 설치가 제대로 되기 시작했다. 모듈 설치단계에서의 에러는 대부분 node 버전 이슈였고, node-sass 에러도 겪어본적이 있어서 노드 버전부터 변경해본거였는데 12까지 낮춰볼 생각을 못했었다ㅠ 어쨌든 해결!


배운것

  1. 노드 버전을 최우선으로 확인하자
  2. 혼자 해결하려는 노력을 1시간을 넘기지 말자.. (누군가 같은 문제 겪었을 가능성)
profile
남는건 기록뿐👩🏻‍💻

0개의 댓글