FS#58129 - [npm] node-gyp path specified in npm files is wrong

Attached to Project: Community Packages
Opened by Michael (Zrax) - Thursday, 05 April 2018, 18:30 GMT
Last edited by Eli Schwartz (eschwartz) - Wednesday, 11 April 2018, 20:06 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Felix Yan (felixonmars)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 8
Private No

Details

Description:
Since updating to npm 5.8.0 (with the new node-gyp 3.6.2), the path specified in some files provided by npm is wrong. Specifically,

* /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp
* /usr/lib/node_modules/npm/bin/node-gyp-bin/node-gyp

both point to "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js", which resolves to "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js", which is no longer valid. This causes scripts and builds that rely on those versions of node-gyp to fail due to being unable to find node-gyp.js:

$ /usr/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
internal/modules/cjs/loader.js:550
throw err;
^

Error: Cannot find module '/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)


Additional info:
* package version(s): npm 5.8.0-1, node-gyp 3.6.2-1
* config and/or log files etc.: See above


Steps to reproduce:
* Attempt to build package 'code' from AUR with latest nodejs, npm, node-gyp.
This task depends upon

Closed by  Eli Schwartz (eschwartz)
Wednesday, 11 April 2018, 20:06 GMT
Reason for closing:  Fixed
Additional comments about closing:  npm 5.8.0-2
Comment by Ilya K (K900) - Wednesday, 11 April 2018, 10:29 GMT
For reference, the correct path is: node "`dirname "$0"`/../../../../node_modules/node-gyp/bin/node-gyp.js" "$@"
Comment by Eli Schwartz (eschwartz) - Wednesday, 11 April 2018, 18:39 GMT
Please try npm 5.8.0-2

I've replaced it to simply exec /usr/bin/node-gyp, there is no reason to not do standard $PATH binaries IMHO.
Comment by Pierre-Alain TORET (daftaupe) - Wednesday, 11 April 2018, 19:32 GMT
Eli,

npm 5.8.0-2 fixes the issue for me, thanks !

Loading...