parcel: npm install fails as node-gyp is unable to build lmdb
π bug report
When trying to install parcel into npm project, npm install --save-dev parcel
fails with exit code 7, complaining about node-gyp failing to build lmdb
package.
π Log
$ npm install --save-dev parcel
npm ERR! code 7
npm ERR! path /tmp/parcel-bug/node_modules/lmdb
npm ERR! command failed
npm ERR! command sh -c node-gyp-build-optional-packages
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@18.2.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.4 found at "/usr/bin/python3"
npm ERR! gyp ERR! UNCAUGHT EXCEPTION
npm ERR! gyp ERR! stack Error: Cannot find module 'request'
npm ERR! gyp ERR! stack Require stack:
npm ERR! gyp ERR! stack - /usr/lib/node_modules/npm/node_modules/node-gyp/lib/install.js
npm ERR! gyp ERR! stack - /usr/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js
npm ERR! gyp ERR! stack - /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
npm ERR! gyp ERR! stack at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
npm ERR! gyp ERR! stack at Module._load (node:internal/modules/cjs/loader:780:27)
npm ERR! gyp ERR! stack at Module.require (node:internal/modules/cjs/loader:1005:19)
npm ERR! gyp ERR! stack at require (node:internal/modules/cjs/helpers:102:18)
npm ERR! gyp ERR! stack at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:10:17)
npm ERR! gyp ERR! stack at Module._compile (node:internal/modules/cjs/loader:1105:14)
npm ERR! gyp ERR! stack at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
npm ERR! gyp ERR! stack at Module.load (node:internal/modules/cjs/loader:981:32)
npm ERR! gyp ERR! stack at Module._load (node:internal/modules/cjs/loader:827:12)
npm ERR! gyp ERR! stack at Module.require (node:internal/modules/cjs/loader:1005:19)
npm ERR! gyp ERR! System Linux 5.17.9-arch1-1
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /tmp/parcel-bug/node_modules/lmdb
npm ERR! gyp ERR! node -v v18.2.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! Node-gyp failed to build your package.
npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/myawesomeusername/.npm/_logs/2022-05-27T10_20_36_304Z-debug-0.log
π Your Environment
Software | Version(s) |
---|---|
Node | v18.2.0 |
npm | 8.5.5 |
Operating System | Arch Linux / x64 |
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 33 (10 by maintainers)
Commits related to this issue
- Use completely separate script names to protect against ambiguous script resolution, https://github.com/parcel-bundler/parcel/issues/8152 — committed to kriszyp/node-gyp-build by kriszyp 2 years ago
- Use completely separate script names to protect against ambiguous script resolution, https://github.com/parcel-bundler/parcel/issues/8152 — committed to kriszyp/node-gyp-build by kriszyp 2 years ago
For me this whole
gyp ERR!
started appearing on just about every other repo I work with when I updated node to v18 (as far as I can remember) and tried to install deps (not just parcel too). Sure enough, downgrading to v16 resolved the entire problem. I am on Windows 10. Writing this possible βfixβ here for anyone not yet wanting to upgrade deps for some reason.got the same error after upgrading Node to v18 ( everything is working properly if I switch node version back to v16 )
I had this issue on M1 MacBook Pro.
npm install -D parcel --ignore-scripts
resolved the issue.The
lmdb
package definitely has precompiled binaries for these OS/architectures and so you should not be needing to locally compiling binaries with python, MSVS, gcc, or anything else. If these are not present, it seems like it may be an issue with the installation not working right, an incompatible package override, or the binaries being deleted or somehow corrupted.I would check to make sure your binaries have been properly installed by NPM first. @rincewindcz, your binary should be at
/tmp/parcel-bug/node_modules/lmdb-linux-x64/node.abi108.node
(from lmdb-linux-x64). @mixaildudin , you binary should be atC:\Users\asdf\Documents\react-app\node_modules\lmdb-win32-x64\node.abi93.node
(from lmdb-win32-x64). (If anyone else wants to know the specific location to check, let me know).If the binary is there, the next thing I would try is to force the npm install to not using any locally compilation by using
--ignore-scripts
and/or making sure thatnode_modules/lmdb/build
folder is deleted/gone and then try loading lmdb with `node -e βconsole.log(require(βlmdbβ))β. If there is some binary corruption or CPU incompatibility issue at the OS level, this should report it.One other thing to check is to make sure that there was no weird package version override and that the correct versions are with
npm ls lmdb node-gyp-build-optional-packages
, which should havelmdb@2.3.10
andnode-gyp-build-optional-packages@4.3.2
. If either of those are wrong, naturally that would cause problems.Hopefully that helps isolate the issue, certainly let me know if you have any questions.
Yet another +1 that downgrading to node v16 (from v19 for me) was a successful (temporary?) fix for me.
@srishilesh msgpackr-extract is not a (required) dependency of gatsby. Or parcel. Or lmdb-js. Or msgpackr. So if you have not explicitly added msgpackr-extract as a dependency in your package.json, this should just be logging noise, not a real failure. Also, this is because node.js v10 is not a supported version of node (according to node.js themselves, and generally unsafe to use due to a lack of security patches).
Ok, trying again with 4.3.5, hopefully the carriage returns are gone now.
Thanks for the help. Noted.
Ok, I published an updated
node-gyp-build-optional-packages
(patch version, should be semver compatible and automatically used). Hopefully this should fix this issue. I canβt reproduce this issue, so I canβt verify it, but at least nothing seems broken from my testing.NPM will rollback failed installation, so
--ignore-scripts
is required to see package content in the first place.node-gyp-build-optional-packages
script invokesnode-gyp-build-test
, butnode-gyp-build
package (required by@parcel/watcher@2.0.5
) also provides anode-gyp-build-test
script, so the prebuilt binary was not detected.node_modules/.bin/node-gyp-build-test
:run
npm install --verbose parcel
:Notice the stacktrace is from
node-gyp-build
package.PS. so funny that it only recognizes
npm install --verbose
, but notnpm install -ddd
Okay, I resolved my issue. I already had VS 2022 Community installed, so I ran the VS installer, checked Node.js tools (and also checked C++ tools for Node.js or something like this), it downloaded 3Gb of data from the internet, now parcel@2.6.0 installs smoothly.
But this is still lame. Looks like someone forgot to include their pre-compiled binaries into the package or something.
Cannot install the new parcel on two machines with Win10, tried with Node 14.16.0, 14.16.1 and 16.15.0.
On one machine npm says it cannot find Python. On the other one it says it cannot find MSVS, and all because of node-gyp and lmdb. Meanwhile, parcel@2.5.0 works ok.
I hope 2.5.0 is not the last version to work on both of my computers. Cause it would be really uncomfortable to install Python, install MSVS and all the necessary build tools for Parcel which used to work like a charm just several days ago, and the main advantage of Parcel is that itβs supposed to work just out of the box!