npm, node-gyp 오류 원인을 도대체 모르겠습니다..

24.02.16 14:54 작성 조회수 362

0

안녕하세요.

개츠비 스타터 템플릿 받는 도중에 아래와 같은 오류가 계속 발생하는데 원인을 정말 모르겠습니다..

일단 제가 해본 것은

  1. node 버전, node-sass 버전 호환 확인 (node : v20.11.1, dart sass : 1.71.0)

  2. npm-cache verify

노드 재설치도 해보고 이 방법 저 방법 해보고 있는데 정말 원인을 모르겠습니다ㅠ

혹시 알려주실 분 계실까요?ㅠㅠ

C:\Users\SEC>npx gatsby new gatsby-starter-ghost https://github.com/TryGhost/gatsby-starter-ghost
info Creating new site from git: https://github.com/TryGhost/gatsby-starter-ghost.git

Cloning into 'gatsby-starter-ghost'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (80/80), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 80 (delta 5), reused 45 (delta 4), pack-reused 0
Receiving objects: 100% (80/80), 303.50 KiB | 2.20 MiB/s, done.
success Created starter directory layout
info Installing packages...

npm ERR! code 1
npm ERR! path C:\Users\SEC\gatsby-starter-ghost\node_modules\@parcel\watcher
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp: binding.gyp not found (cwd: C:\Users\SEC\gatsby-starter-ghost\node_modules\@parcel\watcher) while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\SEC\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:271:18)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:518:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\SEC\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\SEC\gatsby-starter-ghost\node_modules\@parcel\watcher
npm ERR! gyp ERR! node -v v20.11.1
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: C:\Users\SEC\AppData\Local\npm-cache\_logs\2024-02-16T05_22_06_366Z
 ERROR  UNKNOWN

Command failed with exit code 1: npm install --loglevel error --color always --legacy-peer-deps --no-audit



  Error: Command failed with exit code 1: npm install --loglevel error --color always --legacy-peer-deps --no-audit

  - error.js:60 makeError
    [npm]/[gatsby-cli]/[execa]/lib/error.js:60:11

  - index.js:118 handlePromise
    [npm]/[gatsby-cli]/[execa]/index.js:118:26

  - task_queues:95 processTicksAndRejections
    node:internal/process/task_queues:95:5

  - init-starter.js:108 install
    [npm]/[gatsby-cli]/lib/init-starter.js:108:7

  - init-starter.js:163 clone
    [npm]/[gatsby-cli]/lib/init-starter.js:163:3

  - init-starter.js:285 initStarter
    [npm]/[gatsby-cli]/lib/init-starter.js:285:5

  - create-cli.js:405
    [npm]/[gatsby-cli]/lib/create-cli.js:405:9

답변 1

답변을 작성해보세요.

0

인프런 AI 인턴님의 프로필

인프런 AI 인턴

2024.02.17

안녕하세요, 인프런 AI 인턴입니다.

dsyb04님께서 겪고 계신 문제는 node-gyp와 관련된 오류로 보입니다. 오류 메시지 중 "binding.gyp not found"라는 부분에 주목해보면 node-gyp가 필요한 binding.gyp 파일을 찾지 못하는 상황입니다. node-gyp는 일반적으로 C++로 작성된 네이티브 모듈을 컴파일하기 위해 사용되며, Python과 C++ 컴파일러가 필요합니다.

해결 방법은 다음과 같습니다:

  1. Python 2.x 버전과 Python 3.x 버전 중 하나를 설치합니다.
  2. 시스템 환경 변수에 Python 경로를 등록합니다.
  3. Windows의 경우, windows-build-tools 패키지를 글로벌로 설치하여 Visual Studio 빌드 도구를 설치합니다.
    
    npm install --global windows-build-tools
    

  4. 만약 이미 Python이 설치되어 있다면, npm 설정에서 Python 경로를 명시적으로 설정해 줍니다.
    
    npm config set python "C:\path\to\python2.7\python.exe"
    

  5. node-gyp를 최신 버전으로 업데이트합니다.
    
    npm install --global node-gyp@latest
    

  6. 위 단계를 따라도 문제가 해결되지 않는 경우, 사용 중인 노드 버전과 패키지의 호환성 문제일 수 있으므로, nvm(Node Version Manager)을 사용하여 다른 버전의 노드로 전환해 볼 수 있습니다.

위의 단계들을 차례대로 시도해보시기 바랍니다. 추가적으로 gatsby-starter-ghost 템플릿은 현재 사용하고 계신 노드의 특정 버전과 잘 맞지 않을 수 있으므로 호환 가능한 노드 버전에 대한 내용도 확인해보세요.

답변이 도움이 되길 바랍니다. 질문이 더 있으시면 도와드리겠습니다.