node-gyp fails to rebuild during npm install with nvm
See original GitHub issueSorry if this was described in another issue. I could find none like this. Since a few days I get following error when trying to npm i my current project. I tried many different things, including forcing npm to use the latest version as described here. I tried installing my project using different node versions like 16 LTS and 18 LTS.
which node-gyp yields /Users/brunofenzl/.nvm/versions/node/v16.13.0/bin/node-gyp
npm list -g node-gyp yields:
/Users/brunofenzl/.nvm/versions/node/v16.13.0/lib
├─┬ @angular/cli@12.2.17
│ └─┬ pacote@12.0.2
│ └─┬ @npmcli/run-script@2.0.0
│ └── node-gyp@8.4.1
├─┬ ebank-ui@0.0.0 -> ./../../../../../Projects/ebank-ui
│ ├─┬ @angular/cli@12.2.18
│ │ └─┬ pacote@12.0.2
│ │ └─┬ @npmcli/run-script@2.0.0
│ │ └── node-gyp@8.4.1
│ └── node-gyp@9.3.0
├── node-gyp@9.3.0
└─┬ npm@8.1.0
├─┬ @npmcli/run-script@2.0.0
│ └── node-gyp@9.3.0
└── node-gyp@8.2.0
Why isn’t the latest version not being used? Any ideas? Any help much appreciated!
- Node Version: Node 16.13.0 and NPM 8.1.0
- NVM Version: 0.38.0
- Platform: MacOS 12.6.1 (Monterey) Darwin Kernel Version 21.6.0: Thu Sep 29 20:12:57 PDT 2022; root:xnu-8020.240.7~1/RELEASE_X86_64 x86_64
- Compiler: Apple clang version 14.0.0 (clang-1400.0.29.202)
- Python Version: 3.9.6
Verbose output (from npm or node-gyp):
npm timing build:link Completed in 337ms
npm info run fsevents@2.3.2 install node_modules/fsevents node-gyp rebuild
npm info run node-expat@2.4.0 install node_modules/node-expat node-gyp rebuild
npm info run node-sass@7.0.3 install node_modules/node-sass node scripts/install.js
npm info run puppeteer@14.1.1 install node_modules/puppeteer node install.js
npm info run wd@1.14.0 install node_modules/wd node scripts/build-browser-scripts
npm info run wd@1.14.0 install { code: 0, signal: null }
npm timing build:run:install:node_modules/wd Completed in 656ms
npm info run node-sass@7.0.3 install { code: 0, signal: null }
npm timing build:run:install:node_modules/node-sass Completed in 977ms
npm info run fsevents@2.3.2 install { code: 1, signal: null }
npm verb reify failed optional dependency /Users/brunofenzl/Projects/ebank-wp5/node_modules/fsevents
npm timing build:run:install:node_modules/fsevents Completed in 2574ms
npm info run node-expat@2.4.0 install { code: 1, signal: null }
npm timing reify:rollback:createSparse Completed in 14077ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:install Completed in 86138ms
npm verb stack Error: command failed
npm verb stack at ChildProcess.<anonymous> (/Users/brunofenzl/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/index.js:64:27)
npm verb stack at ChildProcess.emit (node:events:390:28)
npm verb stack at maybeClose (node:internal/child_process:1064:16)
npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm verb pkgid node-expat@2.4.0
npm verb cwd /Users/brunofenzl/Projects/ebank-wp5
npm verb Darwin 21.6.0
npm verb argv "/Users/brunofenzl/.nvm/versions/node/v16.13.0/bin/node" "/Users/brunofenzl/.nvm/versions/node/v16.13.0/bin/npm" "i" "--verbose"
npm verb node v16.13.0
npm verb npm v8.1.0
npm ERR! code 1
npm ERR! path /Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! Debugger listening on ws://127.0.0.1:60111/acda4f5e-6b95-4bf7-a5f3-05cc5c0de6b0
npm ERR! For help, see: https://nodejs.org/en/docs/inspector
npm ERR! Debugger attached.
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli '/Users/brunofenzl/.nvm/versions/node/v16.13.0/bin/node',
npm ERR! gyp verb cli '/Users/brunofenzl/Projects/ebank-wp5/node_modules/.bin/node-gyp',
npm ERR! gyp verb cli 'rebuild'
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.0 | darwin | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - executable path is "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp verb find Python - executing "/Applications/Xcode.app/Contents/Developer/usr/bin/python3" to get version
npm ERR! gyp verb find Python - version is "3.9.6"
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 16.13.0
npm ERR! gyp verb command install [ '16.13.0' ]
npm ERR! gyp verb install input version string "16.13.0"
npm ERR! gyp verb install installing version: 16.13.0
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 16.13.0
npm ERR! gyp verb build dir attempting to create "build" dir: /Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat/build
npm ERR! gyp verb build dir "build" dir needed to be created? Yes
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp verb build/config.gypi writing out config file: /Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat/build/config.gypi
npm ERR! gyp verb config.gypi checking for gypi file: /Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat/config.gypi
npm ERR! gyp verb common.gypi checking for gypi file: /Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat/common.gypi
npm ERR! gyp verb gyp gyp format was not specified; forcing "make"
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/brunofenzl/Projects/ebank-wp5/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/brunofenzl/Projects/ebank-wp5/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/brunofenzl/Library/Caches/node-gyp/16.13.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/brunofenzl/Library/Caches/node-gyp/16.13.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/brunofenzl/Projects/ebank-wp5/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/brunofenzl/Library/Caches/node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Debugger listening on ws://127.0.0.1:60127/47e27a82-1255-465c-a3b2-ca5a24aadb48
npm ERR! For help, see: https://nodejs.org/en/docs/inspector
npm ERR! Debugger attached.
npm ERR! Waiting for the debugger to disconnect...
npm ERR! gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. 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.onCpExit (/Users/brunofenzl/Projects/ebank-wp5/node_modules/node-gyp/lib/configure.js:259:16)
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.6.0
npm ERR! gyp ERR! command "/Users/brunofenzl/.nvm/versions/node/v16.13.0/bin/node" "/Users/brunofenzl/Projects/ebank-wp5/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/brunofenzl/Projects/ebank-wp5/node_modules/node-expat
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! Waiting for the debugger to disconnect...
npm verb exit 1
npm timing npm Completed in 86668ms
npm verb unfinished npm timer reify 1667918178925
npm verb unfinished npm timer reify:build 1667918247168
npm verb unfinished npm timer build 1667918247177
npm verb unfinished npm timer build:deps 1667918247178
npm verb unfinished npm timer build:run:install 1667918247576
npm verb unfinished npm timer build:run:install:node_modules/node-expat 1667918247645
npm verb unfinished npm timer build:run:install:node_modules/puppeteer 1667918247740
npm verb code 1
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
trying to 'npm install', getting node-gyp rebuild errors #809
Follow these steps to resolve the issue. 1: Make sure you have build-tools installed. ... 3: Delete package-lock.json and node modules folder and ......
Read more >Node 10 - `node-gyp rebuild` error during npm install
Resolved the issue by updating npm to latest version & running npm rebuild.
Read more >Npm install command failing with message "could not find ...
When I run the npm install command, npm starts downloading the dependencies. But then, suddenly, it stops with the error:
Read more >Solving common issues with node-gyp - LogRocket Blog
js installed, you probably already have node-gyp installed but not exposed globally. If you only need to compile add-ons during the project ...
Read more >I have trouble creating custom components on my device
I can build a project but when I enter the command (npm install or npm ... \\node-gyp\\bin\\node-gyp.js', npm ERR! gyp verb cli 'rebuild', ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, that’s right.
Hi @cclauss!
node-gyp --versionreturns 9.3.0. After much experimenting I found out that installing node-gyp directly as a dev-dependency solves the issue for me. It doesn’t explain though why npm was using the version requested by @angular/cli@12.2.x. This issue can be closed now. Thanks for your help debugging this!