Reputation: 11
I am trying to install sass
with the following command:
npm install node-sass --save-dev
But I am receiving the following error:
internal/modules/cjs/loader.js:626
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 (internal/modules/cjs/loader.js:623:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/share/npm/lib/utils/unsupported.js',
'/usr/share/npm/bin/npm-cli.js'
]
}
I have tried uninstalling/reinstalling npm
but this didn't resolve my error.
So I have tried the following to see if this would help:
sudo rm -rf /usr/lib/node_modules/
sudo rm -rf ~/.npm
brew uninstall --force node
brew install node
But the error still persists.. Any help would be greatly appreciated!
Upvotes: 0
Views: 3366
Reputation: 1
(in ubuntu)
1.- sudo apt install yarn
2.- sudo apt install curl
3.- < look at https://deb.nodesource.com the last version> (now 12):
4.- curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -sudo apt-get install -y nodejs
5.- sudo npm install npm@latest -g
6.- npm -init or npm -version
Upvotes: 0
Reputation: 8149
Perhaps you could try the following steps and seeing if they resolve your issue:
Remove your package-lock.json
file if it exists. It may have gotten out of sorts and is causing locking issues for npm
.
rm package-lock.json
Retry the steps you listed, but instead of removing the node_modules
directory from the /usr/lib/node_modules
directory try removing the node_modules
directory from /usr/local/lib/node_modules
directory.
The steps would be as follows, for more detailed information see this answer:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --force node
brew install node
Node
from official documentationHopefully that helps!
Upvotes: 1