kelektiv / node.bcrypt.js

bcrypt for NodeJs
MIT License
7.43k stars 510 forks source link

Installation failing on ubuntu 20.04.3 (LTS) with node v16.14.0 (LTS) #918

Closed HartS closed 1 year ago

HartS commented 2 years ago

I installed dependencies (python and build-essentials) on a new Ubuntu server. Node was installed through snap (sudo snap install node --classic). npm was updated to the latest version (8.5.0)

The npm install --save bcrypt command is failing (I also tried bcrypt@5.0.0) with vague output:

ubuntu@ip-172-31-6-94:~/test$ npm install --save bcrypt
npm ERR! code 1
npm ERR! path /home/ubuntu/test/node_modules/bcrypt
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2022-02-13T03_11_47_348Z-debug-0.log

With 5.0.0 there is one additional warning:

npm WARN deprecated node-pre-gyp@0.15.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future

Checking the build debug shows nothing helpful... this is the only thing that looks promising:

338 info run bcrypt@5.0.1 install node_modules/bcrypt node-pre-gyp install --fallback-to-build
339 info run bcrypt@5.0.1 install { code: 1, signal: null }
340 timing reify:rollback:createSparse Completed in 57ms
341 timing reify:rollback:retireShallow Completed in 0ms
342 timing command:install Completed in 1511ms
343 verbose stack Error: command failed
343 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
343 verbose stack     at ChildProcess.emit (node:events:520:28)
343 verbose stack     at maybeClose (node:internal/child_process:1092:16)
343 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
HartS commented 2 years ago

I uninstalled node and reinstalled with apt:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

And was able to install bcrypt, so this is somehow specific to the snap installation, even though the node version is the same

recrsn commented 1 year ago

Native modules need access to gcc, and have to load code outside the sandbox. This is not compatible with snap security model