[React] npm install시 node-gyp 에러

KoK·2022년 6월 22일
9

react

목록 보기
1/1

노트북 백업 안해놓고 버티다가ㅎ... 노트북 맛탱이가 감...ㅠㅠ
결국 포맷하고 vscode부터 다시 깔고 시작했는데, 이전에 react로 만들었던 코드를 실행하려고 npm install하니 npm-gyp 에러가 와장창창ㅇ창ㅊ아 나옴...

npm ERR! npm WARN deprecated rollup-plugin-babel@4.3.3: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-babel.
npm ERR! npm WARN deprecated @babel/polyfill@7.4.4: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for 
more information.
npm ERR! npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm ERR! npm WARN deprecated flatten@1.0.2: flatten is deprecated in favor of utility frameworks such as lodash.
npm ERR! npm WARN deprecated rollup-plugin-commonjs@9.3.4: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-commonjs.
npm ERR! npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer 
supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm ERR! npm WARN deprecated svgo@1.3.0: This SVGO version is no longer supported. 
Upgrade to v2.x.x.
npm ERR! npm WARN deprecated svgo@0.7.2: This SVGO version is no longer supported. 
Upgrade to v2.x.x.
npm ERR! npm WARN deprecated iltorb@2.4.3: The zlib module provides APIs for brotli compression/decompression starting with Node.js v10.16.0, please use it over iltorb
npm ERR! npm WARN deprecated core-js@2.6.9: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path C:\Users\wjs41\AppData\Local\npm-cache\_cacache\tmp\git-clonevohD97\node_modules\iltorb
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node ./scripts/install.js || node-gyp rebuild
npm ERR! npm ERR! info install installing standalone, skipping download.
npm ERR! npm ERR! gyp info it worked if it ends with ok
npm ERR! npm ERR! gyp info using node-gyp@9.0.0
npm ERR! npm ERR! gyp info using node@16.15.1 | win32 | x64
npm ERR! npm ERR! gyp info find Python using Python version 3.10.5 found at "C:\Python310\python.exe"
npm ERR! npm ERR! gyp ERR! find VS
npm ERR! npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command 
Prompt
npm ERR! npm ERR! gyp ERR! find VS checking VS2019 (16.11.32602.291) found at:     
npm ERR! npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"       
npm ERR! npm ERR! gyp ERR! find VS - missing any VC++ toolset
npm ERR! npm ERR! gyp ERR! find VS checking VS2017 (15.9.28307.2019) found at:     
npm ERR! npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"       
npm ERR! npm ERR! gyp ERR! find VS - found VC++ toolset: v141
npm ERR! npm ERR! gyp ERR! find VS - missing any Windows SDK
npm ERR! npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! npm ERR! gyp ERR! find VS - not found
npm ERR! npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! npm ERR! gyp ERR! find VS
npm ERR! npm ERR! gyp ERR! find VS **************************************************************
npm ERR! npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows   
npm ERR! npm ERR! gyp ERR! find VS **************************************************************
npm ERR! npm ERR! gyp ERR! find VS
npm ERR! npm ERR! gyp ERR! configure error
npm ERR! npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)      
npm ERR! npm ERR! gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! npm ERR! gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! npm ERR! gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! npm ERR! gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! npm ERR! gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:406:5)
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)     
npm ERR! npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
npm ERR! npm ERR! gyp ERR! System Windows_NT 10.0.19044
npm ERR! npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! npm ERR! gyp ERR! cwd C:\Users\wjs41\AppData\Local\npm-cache\_cacache\tmp\git-clonevohD97\node_modules\iltorb
npm ERR! npm ERR! gyp ERR! node -v v16.15.1
npm ERR! npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! npm ERR! gyp ERR! not ok
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     C:\Users\wjs41\AppData\Local\npm-cache\_logs\2022-06-22T05_52_29_196Z-debug-0.log

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\wjs41\AppData\Local\npm-cache\_logs\2022-06-22T05_51_24_901Z-debug-0.log

어휴^^...
결국 npm-gyp 공식문서 보면서 해결!

https://www.npmjs.com/package/node-gyp

🐱‍👤npm-gyp란?
cross-platform command-line tool 로, native addon modules를 컴파일 해주는 도구.
(native addon modules란 C나 C++로 작성된 동적 링크 공유 객체로 노드의 require() 함수에 의해 로드 되어 일반적인 노드 모듈처럼 사용됨)

덧붙이자면...

  • Node-gyp는 Node.js 자체를 빌드하는 데 사용되진 않음.
  • node-gyp가 nodejs 버전에 필요한 개발 파일 또는 헤더를 알아서 다운하기 때문에 버전에 관계없이 여러버전에서 사용 가능!
  • 설치 명령 : npm install -g node-gyp

😂 node-gyp 오류 해결과정!
오류 해결의 키 포인트는 node-gyp는 python과 visual studio build tools에 의존하기 때문에 이에 대한 셋팅을 해주는 것!

먼저 cmd를 열고...(window 유저임^_^)

  1. npm install --global windows-build-tools
    (현재 node.js에는 window를 위한 build tools이 포함되어 있기 때문에 이 부분은 건너뛰어도 된다고 함. nodejs 깔 때 자동으로 필요한 도구 설치 와 관련된 체크박스가 있는데 여기에 체크 하면 자동설치가 되는 듯! + 그리고 실제로 cmd에서 위 명령실행하니까 자꾸 stuck 됨,,,)

  2. npm config set msvs_version 2017
    (npm config npm 의 설정 조작 명령어, set [이름][값] 을 추가하여 속성을 설정함)

  3. npm config set python /path/to/executable/python
    파이썬의 버전이 node-gyp와 호환가능한 버전인지 확인 후, 만약 설치된 python버전이 여러개라면 그 중 뭘 사용할 것인지 지정해야함!
    (뒤에 주소는 파이썬 툴이 존재하는 경로)
    나의 경우 설치한 파이썬의 버전이 여러개는 아니었지만,,,, 일단 해줌..!ㅎ

  4. npm install --global node-gyp
    (node-gyp 설치)

  5. vs code를 껐다 켜서 다시 npm install 해보니 잘 작동됨!🤣

profile
100% + 100%

0개의 댓글