我安装了 yarn/webpack,然后 npm 崩溃了!我收到以下错误:
npm -v
node:internal/modules/cjs/loader:928
throw err;
^
Error: Cannot find module '../lib/cli.js'
Require stack:
- /usr/local/lib/node_modules/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:997:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:1)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/local/lib/node_modules/npm/bin/npm-cli.js' ]
}
无论我喜欢用 npm 做什么,都会出现错误。我正在使用 Mac OSX 10.14.6
节点版本:15.4.0 纱线版本:1.22.10
感谢您的帮助。
答案 0 :(得分:2)
这发生在我使用 brew install node
时。我通过执行 brew uninstall node
(只是为了清理)然后通过从 https://nodejs.org/
答案 1 :(得分:0)
只需使用 brew uninstall node
卸载,从 https://nodejs.org 下载并安装软件包。