Node-gyp: Builds Fail on WSL

Created on 25 May 2017  ·  13Comments  ·  Source: nodejs/node-gyp

I am having issues building anything with node-gyp in Ubuntu 16.04 under Windows Subsystem for Linux. Is it my error or is node-gyp known to not work under WSL?

I have the following installed:
node-gyp 3.6.1
make (4.1-6)
gcc 4:5.3.1-1ubuntu1
npm 3.10.10
nodejs v6.10.3
python 2.7

I have set the python path using
npm config set python /usr/lib/python2.7

I have verified that Python is installed in that location.

I attempted to install sharp using the command line
sudo npm install sharp --save

I have attached the debug log.
sharp.zip

I also saw failures when trying to install bcrypt with
npm install --build-from-source bcrypt
bcrypt.zip

Any advice would be appreciated. Thanks.

Windows

Most helpful comment

I have same issue and

  1. npm install -g npm
  2. npm install -g node-gyp make

solved problem. I am not sure what caused problem. but works fine now.

All 13 comments

Unfortunately npm doesn't include all the relevant information in the log file. Can you paste the console output?

One immediate issue is that gcc 4.5 is too old to build anything for node.js v6.x, you're going to need at least gcc/g++ 4.8.5.

I upgraded to gcc 4.8.5, still the same error though.

Console output:

gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn EACCES
gyp ERR! stack     at exports._errnoException (util.js:1018:11)
gyp ERR! stack     at ChildProcess.spawn (internal/child_process.js:319:11)
gyp ERR! stack     at exports.spawn (child_process.js:378:9)
gyp ERR! stack     at exports.execFile (child_process.js:143:15)
gyp ERR! stack     at checkPythonVersion (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:419:5)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:361:9
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:88:20
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Linux 4.4.0-43-Microsoft
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /mnt/d/Projects/Estimake/node_modules/sharp
gyp ERR! node -v v6.10.3
gyp ERR! node-gyp -v v3.4.0
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.4.0-43-Microsoft
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "sharp" "--save"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls sharp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/d/Projects/Estimake/npm-debug.log

Is that the full build output? Can you try upgrading to [email protected]? There have been quite a few fixes to the python detection logic since 3.4.0.

I upgraded to 3.6.1 and reran the sharp install, piping the output to a log file. This is the entire contents of that log file. (Also I gave up trying to get this to run in WSL and moved my dev environment back to Windows, but I can continue to test things if it would be helpful).

> [email protected] install /mnt/d/Projects/Estimake/node_modules/sharp
> node-gyp rebuild

gyp ERR! UNCAUGHT EXCEPTION 
gyp ERR! stack Error: spawn EACCES
gyp ERR! stack     at exports._errnoException (util.js:1018:11)
gyp ERR! stack     at ChildProcess.spawn (internal/child_process.js:319:11)
gyp ERR! stack     at exports.spawn (child_process.js:378:9)
gyp ERR! stack     at exports.execFile (child_process.js:143:15)
gyp ERR! stack     at checkPythonVersion (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:419:5)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:361:9
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:88:20
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Linux 4.4.0-43-Microsoft
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /mnt/d/Projects/Estimake/node_modules/sharp
gyp ERR! node -v v6.10.3
gyp ERR! node-gyp -v v3.4.0
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.4.0-43-Microsoft
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "sharp"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 7
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls sharp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/d/Projects/Estimake/npm-debug.log

@Bluejay47 since node-gyp comes with the installation on npm, it seems like it still uses the old version.
from your output:

...
gyp ERR! node -v v6.10.3
gyp ERR! node-gyp -v v3.4.0
...
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
...

Could you try and update npm to version 4.6.1
On my WSL I had to do the following:

refael@refaelux:~/npm/global$ cd /usr/lib
refael@refaelux:/usr/lib$ sudo npm i [email protected]
/usr/lib
└── [email protected]
...
refael@refaelux:/usr/lib$ npm -v
4.6.1

I updated NPM to 5.0.1 - exact same results. I have verified that both the PYTHON and PYTHONPATH environment variables are set to the correct location but it still complains that it can not detect python. Since it works for you on WSL I will assume there is something wrong with my installation. I'll just blow it away and start again. Thanks for your assistance with this.

@Bluejay47 run a which npm, I think newer versions of WSL can call Windows' exe and bat files. Maybe that's it.

This is still an issue.

This is happening to me too, see: https://github.com/kelektiv/node.bcrypt.js/issues/751 for the full build failure details.

This still seems an issue, I am running VS on a WSL (Windows Subsystem for Linux) and when I am trying to do ‘npm install’ I am getting an error which says
make: Leaving directory ‘/home/rishabh/customer-management-api/node_modules/couchbase/build’
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/rishabh/.nvm/versions/node/v13.3.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:219:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
gyp ERR! System Linux 4.4.0-18362-Microsoft
gyp ERR! command “/home/rishabh/.nvm/versions/node/v13.3.0/bin/node” “/home/rishabh/.nvm/versions/node/v13.3.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /home/rishabh/customer-management-api/node_modules/couchbase
gyp ERR! node -v v13.3.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: prebuild-install || node-gyp rebuild
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.

Intially this seems couchbase issue, so I reached them. But they also redirected to npm-gyp issues, anyone out there who can help?
attached is debug log.
npm_install_error.zip

on WSL2, latest updates, still getting the problem, tried all fixes:

bindings.target.mk:128: recipe for target 'Release/obj.target/bindings/src/bindings.o' failed
make: * [Release/obj.target/bindings/src/bindings.o] Error 1
make: Leaving directory '/home/ahmad/.nvm/versions/node/v13.12.0/lib/node_modules/jscast/node_modules/lame/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/ahmad/.nvm/versions/node/v13.12.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.19.104-microsoft-standard
gyp ERR! command "/home/ahmad/.nvm/versions/node/v13.12.0/bin/node" "/home/ahmad/.nvm/versions/node/v13.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ahmad/.nvm/versions/node/v13.12.0/lib/node_modules/jscast/node_modules/lame
gyp ERR! node -v v13.12.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
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! /home/ahmad/.npm/_logs/2020-04-19T05_44_38_617Z-debug.log

@Bluejay47 have you finally made it? I have also an issue with making node-gyp work on WSL

I have same issue and

  1. npm install -g npm
  2. npm install -g node-gyp make

solved problem. I am not sure what caused problem. but works fine now.

Was this page helpful?
0 / 5 - 0 ratings