Ramya D
Ramya D

Reputation: 11

how to fix the problem when i run any command regarding to npm it shows error

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)

Upvotes: 1

Views: 1745

Answers (1)

Akansha Gadhvi
Akansha Gadhvi

Reputation: 51

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.

Upvotes: 3

Related Questions