Cli: Update node-gyp to v6.x

Created on 6 Nov 2019  路  8Comments  路  Source: npm/cli

What / Why

Update node-gyp dependency to v6.x to fix build issues on macOS

When

  • When installing packages with node-gyp builds on macOS

Where

  • NPM CLI (install command)

How

Current Behavior

  • Causes errors on python3 and latest Xcode (see nodejs/node-gyp#1917)

Expected Behavior

  • Install packages successfully

Who

  • Any package with native code that does not have a pre-built binary it can use

References

  • Related to nodejs/node-gyp#1917
Bug

Most helpful comment

This is updated in npm 7 to v6 in https://github.com/npm/cli/commit/09dac89c1bc20eb2c1f1f272c9e07fc1a579d75a (and to node-gyp v7 in https://github.com/npm/cli/commit/b3a50d27501e47c61b52c3cc4de99ff4e4641efe)

All 8 comments

I had to update node-gyp dependency manually to 6.0.1 in one of our mac boxes to avoid the 'TypeError: cannot use a string pattern on a bytes-like object' error:
https://github.com/atom/git-utils/issues/72#issuecomment-553453209

I'm trying to install npm 6.13.4 with node-js 13.5.0 and ran into the same Python 3 issue reported in https://github.com/nodejs/node-gyp/issues/1917

I'm installing both node-js and npm from source. I tried replacing node_modules/node-gyp (version 5.0.5) with version 6.0.1 in the npm source tarball, then updated package.json with the new version. Now I'm getting the following error:

> node install

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v79-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v79 ABI, unknown) (falling back to source compile with node-gyp) 
make[1]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
  COPY /private/var/folders/21/hwq39zyj4g36x6zjfyl5l8080000gn/T/Adam/spack-stage/spack-stage-npm-6.13.4-m5vzriomllzvhxm6okvb6oy2zs2nnhus/spack-src/docs/node_modules/fsevents/lib/binding/Release/node-v79-darwin-x64/fse.node
  TOUCH Release/obj.target/action_after_build.stamp

> [email protected] install /private/var/folders/21/hwq39zyj4g36x6zjfyl5l8080000gn/T/Adam/spack-stage/spack-stage-npm-6.13.4-m5vzriomllzvhxm6okvb6oy2zs2nnhus/spack-src/docs/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /Users/Adam/.npm/_libvips/libvips-8.7.4-darwin-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=13.5.0 runtime=node arch=x64 libc= platform=darwin)
make[1]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
  CXX(target) Release/obj.target/sharp/src/metadata.o
  CXX(target) Release/obj.target/sharp/src/stats.o
../src/stats.cc:130:19: error: no matching member function for call to 'Set'
        channels->Set(i, channelStat);
        ~~~~~~~~~~^~~
/Users/Adam/Library/Caches/node-gyp/13.5.0/include/node/v8.h:3547:37: note: candidate function not viable: requires 3 arguments, but 2 were provided
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                    ^
/Users/Adam/Library/Caches/node-gyp/13.5.0/include/node/v8.h:3550:37: note: candidate function not viable: requires 3 arguments, but 2 were provided
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                    ^
1 error generated.
make[1]: *** [Release/obj.target/sharp/src/stats.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/private/var/folders/21/hwq39zyj4g36x6zjfyl5l8080000gn/T/Adam/spack-stage/spack-stage-npm-6.13.4-m5vzriomllzvhxm6okvb6oy2zs2nnhus/spack-src/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:305:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/Users/Adam/spack/opt/spack/darwin-catalina-x86_64/clang-11.0.0-apple/node-js-13.5.0-k6hflaned2pgrkezljfpgsjy2hgkrgfe/bin/node" "/private/var/folders/21/hwq39zyj4g36x6zjfyl5l8080000gn/T/Adam/spack-stage/spack-stage-npm-6.13.4-m5vzriomllzvhxm6okvb6oy2zs2nnhus/spack-src/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /private/var/folders/21/hwq39zyj4g36x6zjfyl5l8080000gn/T/Adam/spack-stage/spack-stage-npm-6.13.4-m5vzriomllzvhxm6okvb6oy2zs2nnhus/spack-src/docs/node_modules/sharp
gyp ERR! node -v v13.5.0
gyp ERR! node-gyp -v v6.0.1
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Adam/.npm/_logs/2019-12-20T02_40_06_941Z-debug.log
make: *** [htmldocs] Error 1

Am I doing something wrong? Very new to node, just need it as a dependency of a dependency.

Hmm, looks like the version of sharp may need to be updated to support node.js 13: https://github.com/lovell/sharp/issues/2005

Re node-gyp v5 and v6 and the suggestion here that this is caused by not having 6 (it's not, and it's not that simple): https://github.com/nodejs/node-gyp/issues/1917#issuecomment-570411606

Also, you can help us fix this if you're experiencing this problem. See link.

Posting here for anything troubleshooting installing deps without a pre-built binary available:
In the meantime you can manually update node-gyp https://github.com/nodejs/node-gyp/wiki/Updating-npm's-bundled-node-gyp

This bug is causing issues in 3 upstream packages I use. And it is not just OSX, it is all of linux. Title should be updated to include linux.

This is updated in npm 7 to v6 in https://github.com/npm/cli/commit/09dac89c1bc20eb2c1f1f272c9e07fc1a579d75a (and to node-gyp v7 in https://github.com/npm/cli/commit/b3a50d27501e47c61b52c3cc4de99ff4e4641efe)

Was this page helpful?
0 / 5 - 0 ratings