1

when I use the command any command associated with npm, it's not working how to fix the problem. can anyone please help me to solve the problem. I used the commands

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

after that, I get problems in npm

npm -v
internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module 'semver'
at Function.Module._resolveFilename 
(internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> 
(/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js 
(internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Hasitha Jayawardana
  • 2,326
  • 4
  • 18
  • 36
Ramya D
  • 11
  • 2
  • try reinstalling the npm. – Indrajeet Latthe Jun 27 '19 at 06:56
  • Possible duplicate of [Npm install cannot find module 'semver'](https://stackoverflow.com/questions/33870520/npm-install-cannot-find-module-semver) – sandrooco Jun 27 '19 at 06:56
  • Try reinstalling: these steps will help. https://askubuntu.com/questions/1036806/how-to-remove-npm-and-reinstall-npm-completely-in-18-04 – Sanjeet kumar Jun 27 '19 at 06:57
  • i followed the steps . but i can't get anything from (https://stackoverflow.com/questions/33870520/npm-install-cannot-find-module-semver) @sandrooco – Ramya D Jun 27 '19 at 07:06

1 Answers1

3

I had the same problem. I solved this problem by uninstalling node_modules and then deleting both the npm and npm-cache folders in %APPDATA%and finally installing the complete node_moodules again.

You can use these steps to remove node_modules:

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

I hope this will help to solve your problem.