openhab / openhab-cloud

Cloud companion for openHAB instances
Eclipse Public License 2.0
313 stars 162 forks source link

npm failed on ubuntu 20.04 vps #314

Open Dual-0 opened 3 years ago

Dual-0 commented 3 years ago

Hi Guys,

I've got this error on the installation step "npm install"

edit: I've run the "dependabot/npm_and_yarn/bcrypt-5.0.0" branch... got this errors too

morph166955 commented 3 years ago

I have this same issue.

make: *** [validation.target.mk:104: Release/obj.target/validation/src/validation.o] Error 1 make: Leaving directory '/root/openhab-cloud/node_modules/utf-8-validate/build' gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/share/nodejs/node-gyp/lib/build.js:194:23) gyp ERR! stack at ChildProcess.emit (events.js:198:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) gyp ERR! System Linux 5.4.0-45-generic gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild" gyp ERR! cwd /root/openhab-cloud/node_modules/utf-8-validate gyp ERR! node -v v10.19.0 gyp ERR! node-gyp -v v6.1.0 gyp ERR! not ok

bcrypt@1.0.2 install /root/openhab-cloud/node_modules/bcrypt node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v64-linux-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for bcrypt@1.0.2 and node@10.19.0 (node-v64 ABI) (falling back to source compile with node-gyp) node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v64-linux-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for bcrypt@1.0.2 and node@10.19.0 (node-v64 ABI) (falling back to source compile with node-gyp) make: Entering directory '/root/openhab-cloud/node_modules/bcrypt/build' CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o make: Entering directory '/root/openhab-cloud/node_modules/bcrypt/build' CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o sed: can't read ./Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw: No such file or directory rm: cannot remove './Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw': No such file or directory make: *** [bcrypt_lib.target.mk:105: Release/obj.target/bcrypt_lib/src/blowfish.o] Error 1 make: Leaving directory '/root/openhab-cloud/node_modules/bcrypt/build' gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/share/nodejs/node-gyp/lib/build.js:194:23) gyp ERR! stack at ChildProcess.emit (events.js:198:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) gyp ERR! System Linux 5.4.0-45-generic gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "build" "--fallback-to-build" "--module=/root/openhab-cloud/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/root/openhab-cloud/node_modules/bcrypt/lib/binding" gyp ERR! cwd /root/openhab-cloud/node_modules/bcrypt gyp ERR! node -v v10.19.0 gyp ERR! node-gyp -v v6.1.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/bin/node-gyp build --fallback-to-build --module=/root/openhab-cloud/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/root/openhab-cloud/node_modules/bcrypt/lib/binding' (1) node-pre-gyp ERR! stack at ChildProcess. (/root/openhab-cloud/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:198:13) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:982:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) node-pre-gyp ERR! System Linux 5.4.0-45-generic node-pre-gyp ERR! command "/usr/bin/node" "/root/openhab-cloud/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /root/openhab-cloud/node_modules/bcrypt node-pre-gyp ERR! node -v v10.19.0 node-pre-gyp ERR! node-pre-gyp -v v0.6.32 node-pre-gyp ERR! not ok

morph166955 commented 3 years ago

I've now tested this on Ubuntu 16, 18, and 20. All fail for different reasons. bcrypt seems to work on 18 and 16, but fail with the following errors:

npm ERR! typeerror Error: Missing required argument #1 npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3) npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22) npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12) npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7 npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50 npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12 npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5) npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7) npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20) npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50 npm ERR! typeerror This is an error with npm itself. Please report this error at: npm ERR! typeerror http://github.com/npm/npm/issues

node versions have been 4.x and 8.x as that is what is current in the ubuntu repos.

morph166955 commented 3 years ago

Apparently the nodejs version HAS to be 7.10.1. Instead of using APT to install nodejs, go to https://nodejs.org/dist/v7.10.1/ and pull the gz down. You are going to have to manually install it into /usr. Then npm install works.

morph166955 commented 3 years ago

You will also need to run:

npm install bcrypt bcryptjs@^2.4.3 qunitjs@^2.0.0 npm install time node-time

That seemed to fix a few things that didn't work properly after npm install runs.

morph166955 commented 3 years ago

Also run "mongo" and then run:

db.createUser( { user: "openhab", pwd: "openhab", roles: [ { role: "readWrite", db: "openhab" } ] } )

giddel commented 3 years ago

Apparently the nodejs version HAS to be 7.10.1. Instead of using APT to install nodejs, go to https://nodejs.org/dist/v7.10.1/ and pull the gz down. You are going to have to manually install it into /usr. Then npm install works.

... and be aware that after copy /usr/bin/npm is still a symlink to ../lib/node_modules/npm/bin/npm-cli.js ... else you get only Error: Cannot find module '../lib/utils/unsupported.js' when calling npm