简体   繁体   中英

Cannot find module 'semver' When installing Npm

This is the error i got when try to install npm. please help me to fix it.

module.js:549
    throw err;
    ^

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\maheshig\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js:2:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

In linux you can use the following

sudo rm -rf /usr/lib/node_modules/

or wherever your global node_modules are

then reinstall npm

this solved the problem with me.

I followed These steps and it solved my issue

  1. uninstall Node.js
  2. Remove the content of the following folders C:\\Users\\AppData\\Roaming\\npm-cache C:\\Users\\AppData\\Roaming\\npm C:\\Program Files\\nodejs
  3. Then again install Node https://nodejs.org/en/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM