Search code examples
node.jsnpmautomationbackendnode-modules

I did npm i -g npm@5.5.1 after that I am not able see npm -v , throwing error


 npm -v

node:internal/modules/cjs/loader:936 throw err; ^

Error: Cannot find module 'semver' Require stack:

Before this npm -v showing 8. some version but now it's throwing error how can i resolve this or undo?


Solution

  • Try the below command if you are using Linux: It will clean install the latest version of npm. It will also remove the previous version of npm

    sudo curl -qL https://www.npmjs.com/install.sh | sh