Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install with command failed sh -c node-gyp rebuild #2123

Closed
mcfarljw opened this issue Jan 29, 2024 · 6 comments
Closed

Unable to install with command failed sh -c node-gyp rebuild #2123

mcfarljw opened this issue Jan 29, 2024 · 6 comments

Comments

@mcfarljw
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v20.11.0
  • Nuxt Version: -
  • CLI Version: 3.10.0
  • Nitro Version: -
  • Package Manager: unknown
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

Run the following commands:

  1. npx giget@latest nitro nitro-app
  2. cd nitro-app
  3. npm install

Describe the bug

The install fails because it seems like there might be some issue with a nitropack dependency on @parcel/watcher. Specifically this is only happening with version 2.20 and greater of that dependency, 2.1.0 works as expected.

Additional context

Everything was working fine for me until today when I did a clean install (rm package-lock.json && rm -rf node_modules && npm install). The only way to fix the issue for me is to override the @parcel/watcher version as follows:'

"overrides": {
    "@parcel/watcher": "2.1.0"
  },

When I run npm ls @parcel/watcher it seems to show that dependency is coming from a nitropack dependency:

nuxt@3.9.3
  ├── @parcel/watcher@2.1.0 overridden
  └─┬ nitropack@2.8.1
    └─┬ listhen@1.6.0
      └── @parcel/watcher@2.1.0 deduped

This seems to also be an issue that has been reported here parcel-bundler/watcher#156 and parcel-bundler/watcher#153 as well with other Nuxt users experiencing the same issue.

I also opened nuxt/nuxt#25478 for the same thing but was directed here.

Logs

npm ERR! code 1
npm ERR! path /Users/joshua/Desktop/nitro-app/node_modules/@parcel/watcher
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.11.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.12.1 found at "/Users/joshua/.pyenv/versions/3.12.1/bin/python3"
npm ERR! gyp info spawn /Users/joshua/.pyenv/versions/3.12.1/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/joshua/.nvm/versions/node/v20.11.0/lib/node_modules/npm/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/joshua/Desktop/nitro-app/node_modules/@parcel/watcher/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/joshua/.nvm/versions/node/v20.11.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/joshua/Library/Caches/node-gyp/20.11.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/joshua/Library/Caches/node-gyp/20.11.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/joshua/.nvm/versions/node/v20.11.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/joshua/Library/Caches/node-gyp/20.11.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/joshua/Desktop/nitro-app/node_modules/@parcel/watcher',
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! gyp: binding.gyp not found (cwd: /Users/joshua/Desktop/nitro-app/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> (/Users/joshua/.nvm/versions/node/v20.11.0/lib/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 Darwin 23.3.0
npm ERR! gyp ERR! command "/Users/joshua/.nvm/versions/node/v20.11.0/bin/node" "/Users/joshua/.nvm/versions/node/v20.11.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/joshua/Desktop/nitro-app/node_modules/@parcel/watcher
npm ERR! gyp ERR! node -v v20.11.0
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: /Users/joshua/.npm/_logs/2024-01-29T10_56_15_369Z-debug-0.log
@DJviolin
Copy link

DJviolin commented Feb 2, 2024

Maybe unrelated, but I experiencing a node-gyp issue in Windows.

Versions

C:\www-docker>node -v
v21.6.1

C:\www-docker>npm -v
10.4.0

C:\www-docker>python3 --version
Python 3.12.1
Python 3.11.7 (same error with both version)

C:\www-docker>npm list -g --depth=0
c:\Program Files\nodejs -> .\
+-- corepack@0.24.1
+-- node-gyp@10.0.1
`-- npm@10.4.0

Latest Visual Studio Community 2022 is installed with desktop C++ built tools.

Error message

C:\www-docker>npx nuxi@latest init nuxt-example

✔ Which package manager would you like to use?
npm
◐ Installing dependencies...                                                                                  22:03:30
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\www-docker\\nuxt-example\\node_modules\\@nuxt',
npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\www-docker\nuxt-example\node_modules\@nuxt\devtools\dist\client'] {
npm WARN cleanup       errno: -4048,
npm WARN cleanup       code: 'EPERM',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\www-docker\\nuxt-example\\node_modules\\@nuxt\\devtools\\dist\\client'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\www-docker\nuxt-example\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 info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@21.6.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.11.7 found at "C:\Users\User\.pyenv\pyenv-win\versions\3.11.7\python3.exe"
npm ERR! gyp info find VS using VS2022 (17.8.34525.116) found at:
npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\User\.pyenv\pyenv-win\versions\3.11.7\python3.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args 'C:\\www-docker\\nuxt-example\\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 'msvs',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\www-docker\\nuxt-example\\node_modules\\@parcel\\watcher\\build\\config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\www-docker\\nuxt-example\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\Users\\User\\AppData\\Local\\node-gyp\\Cache\\21.6.1\\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=C:\\Users\\User\\AppData\\Local\\node-gyp\\Cache\\21.6.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\\www-docker\\nuxt-example\\node_modules\\node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\User\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\21.6.1\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=C:\\www-docker\\nuxt-example\\node_modules\\@parcel\\watcher',
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 'C:\\www-docker\\nuxt-example\\node_modules\\@parcel\\watcher\\build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: binding.gyp not found (cwd: C:\www-docker\nuxt-example\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:\www-docker\nuxt-example\node_modules\node-gyp\lib\configure.js:271:18)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:519: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.22631
npm ERR! gyp ERR! command "c:\\program files\\nodejs\\node.exe" "C:\\www-docker\\nuxt-example\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\www-docker\nuxt-example\node_modules\@parcel\watcher
npm ERR! gyp ERR! node -v v21.6.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\User\AppData\Local\npm-cache\_logs\2024-02-02T21_03_31_154Z-debug-0.log

 ERROR  Error: Command failed with exit code 1: npm install

@mcfarljw
Copy link
Author

mcfarljw commented Feb 2, 2024

@DJviolin the error stack looks almost identical. Thanks for sharing, I was thinking with might have been only a macOS issue because I couldn't reproduce it using services like StackBlitz.

If you add the following to package.json then do a clean install does it work?

"overrides": {
   "@parcel/watcher": "2.1.0"
},

@DJviolin
Copy link

DJviolin commented Feb 3, 2024

Thank You, your solution works! I tested both with an official example and in my local project in Windows. Interestingly, in WSL Docker it works without the package override. I tried all newest versions from "@parcel/watcher" and v2.1.0 the last one that works.

@f-lapinski
Copy link

Solution with add

"overrides": { "@parcel/watcher": "2.1.0" }

before choose a package manager, works great!

@devongovett
Copy link

Please try @parcel/watcher v2.4.1, which should fix this issue with npm 10.4.0. See parcel-bundler/watcher#156 (comment) for details.

@manniL
Copy link
Contributor

manniL commented Feb 24, 2024

Thanks Devon!

Closing here ☺️

@manniL manniL closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants