简体   繁体   English

安装 Npm 时找不到模块“semver”

[英]Cannot find module 'semver' When installing Npm

This is the error i got when try to install npm.这是我尝试安装 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在linux中,您可以使用以下

sudo rm -rf /usr/lib/node_modules/

or wherever your global node_modules are或者你的全局 node_modules 在哪里

then reinstall npm然后重新安装npm

this solved the problem with me.这解决了我的问题。

I followed These steps and it solved my issue我按照这些步骤,它解决了我的问题

  1. uninstall Node.js卸载 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删除以下文件夹的内容 C:\\Users\\AppData\\Roaming\\npm-cache C:\\Users\\AppData\\Roaming\\npm C:\\Program Files\\nodejs
  3. Then again install Node https://nodejs.org/en/然后再次安装 Node https://nodejs.org/en/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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