npm broken Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
Post Reply
kazgor
Posts: 34
Joined: Sun Dec 17, 2017 10:18 pm

npm broken

Post by kazgor »

Hi.

i was just upgrading node-red to the latest 1.2.9 (from .1.2.7) and ran the NPM command to do the update.

Code: Select all

npm up -g --unsafe-perm node-red
but before it would do it NPM reported there was a minor update to do first and run this first

Code: Select all

npm install -g npm@7.5.2
after doing that.. if it then ran any NPM command it would now say NPM not found.

so i thought maybe somehow it has remove it self so did

Code: Select all

apt-get install -y npm
but that now is just worse as it think it v5.8.0 and now it just crashes

Code: Select all

Error: Cannot find module 'semver'
Require stack:
- /usr/share/npm/lib/utils/unsupported.js
- /usr/share/npm/bin/npm-cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/npm/lib/utils/unsupported.js',
    '/usr/share/npm/bin/npm-cli.js'
  ]
node -v brings back v15.5.0 and Node-Red is running ok. but what have i now gone and messed up
as means i wont be able to use NPM .

thanks.
kazgor
Posts: 34
Joined: Sun Dec 17, 2017 10:18 pm

Re: npm broken

Post by kazgor »

looks like i accidently fixed it.

I fired up a VM copy dietpi so i can try to replicate it on there so as not to make the main system worse.

As the VM didnt have Node-Red on there i want to get that on it.

so did Dietpi-software Install 140

HOWEVER!!

Here is the accident.

1. I ended up doing that command on the live box rather than the VM.. i forgot which putty windows was the VM.
2. software 140 is not node-red but Domoticz

so effectively i ended up installing Domoticz on to to the Main system... and funny enough whatever
the install did.. NPM is now working again.

I can do npm - v and get back 7.5.2 fine.

So i now uninstalled Domoticz and everything is still all working.


so yeah all fine now. ta


fix was also to use

Code: Select all

curl -qL https://www.npmjs.com/install.sh | sh
Last edited by kazgor on Sun Apr 11, 2021 7:10 pm, edited 2 times in total.
User avatar
Joulinar
Posts: 5162
Joined: Sat Nov 16, 2019 12:49 am

Re: npm broken

Post by Joulinar »

that's indeed strange because Domoticz did not install anything related to npm.

The only thing I could imagine is probably a package update initiated by by dietpi-software as it is running apt update && apt upgrade in front of every software installation. Maybe it fixed your npm issue.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply