Not able to run any npm command due to following error - Error: Cannot find module 'semver'
Not able to run any npm command due to following error - Error: Cannot find module 'semver'
之前节点工作正常。
之后因为我想安装 express & socket.io.
它要求节点版本更新。
我试图更新节点版本&我相信我在更新过程中忘记了一些命令运行。
现在它在任何 npm 命令上都给出以下错误。即使我只输入 npm,也会出错。
m@m-Lenovo-ideapad-320-15IKB:/var/www/html/chat$ npm -v
nternal/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:692: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:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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)
终于解决了,我认为下面的过程有效。
- 已从 usr 文件夹中删除 npm 模块
- 我删除了 npm 模块
- 清除缓存
- 已安装 npm
& 成功了
我犯的错误是没有清除缓存
之前节点工作正常。
之后因为我想安装 express & socket.io.
它要求节点版本更新。
我试图更新节点版本&我相信我在更新过程中忘记了一些命令运行。
现在它在任何 npm 命令上都给出以下错误。即使我只输入 npm,也会出错。
m@m-Lenovo-ideapad-320-15IKB:/var/www/html/chat$ npm -v nternal/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:692: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:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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)
终于解决了,我认为下面的过程有效。
- 已从 usr 文件夹中删除 npm 模块
- 我删除了 npm 模块
- 清除缓存
- 已安装 npm
& 成功了
我犯的错误是没有清除缓存