[solved] Cannot install/use npm in Ubuntu 16.04 LTS

Dear all, on an older laptop, used for a lot of things, I would like to use node-red.

I tried so many things and at least I see:

$ node -v
v14.10.1

npm -v
6.14.8

but I had some warnings also,and I cannot install node red:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/2020-09-15T19_44_58_774Z-debug.log

log content:

If I remember well, it was always mentioned that there somewhere in ?owncloud? is no release candidate..

So how can I fix this problem / I really tried a lot. what do I need to uninstall if so and how to install correctly again?

I'm willing to learn and go step by step / share with you..

What actual command did you run?

From that log it looks like you ran npm install -g - which would fail with the error you see because you haven't specified a package name to install.

To install Node-RED, you'd use npm install -g node-red

Don't you need this?
sudo npm -g install --unsafe-perm node-red

However, on Ubuntu you can normally use the recommended Debian/Ubuntu/Raspbian script to install or update node red, though I am not absolutely certain that it works with Ubuntu 16.04. https://nodered.org/docs/getting-started/raspberrypi

gives:

$ npm install -g node-red
npm WARN deprecated bcrypt@3.0.6: versions < v5.0.0 do not handle NUL in passwords properly
npm WARN deprecated request@2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated bcrypt@3.0.8: versions < v5.0.0 do not handle NUL in passwords properly
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rainer/.npm/_logs/2020-09-15T20_18_15_701Z-debug.log


now trying with sudo:

$ sudo npm install -g node-red
[sudo] Passwort für rainer: 
npm WARN deprecated bcrypt@3.0.6: versions < v5.0.0 do not handle NUL in passwords properly
npm WARN deprecated request@2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated bcrypt@3.0.8: versions < v5.0.0 do not handle NUL in passwords properly
/usr/local/bin/node-red -> /usr/local/lib/node_modules/node-red/red.js
/usr/local/bin/node-red-pi -> /usr/local/lib/node_modules/node-red/bin/node-red-pi

> bcrypt@3.0.8 install /usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for bcrypt@3.0.8 and node@14.10.1 (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib' 
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/build'
gyp ERR! System Linux 4.4.0-189-generic
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib/binding" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd /usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt
gyp ERR! node -v v14.10.1
gyp ERR! node-gyp -v v5.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/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib/binding --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1047:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
node-pre-gyp ERR! System Linux 4.4.0-189-generic
node-pre-gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt
node-pre-gyp ERR! node -v v14.10.1
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/usr/local/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib/binding --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: bcrypt@3.0.8 (node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: bcrypt@3.0.8 install: `node-pre-gyp install --fallback-to-build`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ node-red@1.1.3
added 17 packages from 20 contributors, removed 165 packages, updated 1 package and moved 302 packages in 14.601s

Which shows a successful installation of Node-RED 1.1.3.

There were some errors compiling the optional bcrypt dependency, but they are not fatal.

I did this:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

(running)..

result:

Running Node-RED update for user rainer at /home/rainer on ubuntu


This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       -
  Leave existing Node.js              -   Node v14.10.1   Npm 6.14.8
  Clean npm cache                     -
  Install Node-RED core               ✔   1.1.3 
  Move global nodes to local          ✔
  Install extra Pi nodes              -
  Npm rebuild existing nodes          -
  Add shortcut commands               ✔
  Update systemd script               ✔
                                      

Any errors will be logged to   /var/log/nodered-install.log
All done.
  You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
  Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started  Di 15. Sep 22:24:46 CEST 2020  -  Finished  Di 15. Sep 22:25:34 CEST 2020




YESS! it works - thank you! I did it before without succes, but now its ok!!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.