1

I reinstalled ubuntu on my machine and after that installed node, react, npm, when i tried to start old project and run into same error when i started the project but also when i tried to see version of npm.

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

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:924:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:996: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:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19) {
  code: 'MODULE_NOT_FOUND',
   requireStack: [
    '/usr/share/npm/lib/utils/unsupported.js',
    '/usr/share/npm/bin/npm-cli.js'
  ]
}

I uninstalled and installed npm again but it didnt help

A1ed5gh
  • 11
  • 1

2 Answers2

0

Try this link anotehr SO post

Basically what they are doing is the below steps:

sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --force node
brew install node

replace brew with respective package manager

HexaCrop
  • 3,863
  • 2
  • 23
  • 50
0

You generally don't need to install npm separately. npm is bundled with node and the version that is bundled will generally work with the version of node you are running. If you install npm separately, you run the risk of installing an incompatible version of node.

So uninstall npm. See if you still have an npm available. If not, uninstall and reinstall node. Do not install npm separately (unless it is using npm itself to update to a newer version of npm with npm install -g npm.)

Trott
  • 66,479
  • 23
  • 173
  • 212