[英]How do i fix 'npm init' and not being able to upgrade it
我已經 3 年沒有接觸過節點或編碼了有誰知道如何修復這個npm init
node:internal/modules/cjs/loader:922
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:919:15)
at Function.Module._load (node:internal/modules/cjs/loader:763:27)
at Module.require (node:internal/modules/cjs/loader:991: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:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807: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' ]
}
我做了
brew upgrade node
在此之前並嘗試過
brew upgrade npm
並給我
Warning: npm 15.3.0 already installed
我通過重命名位於“/usr/local/lib”中的 node_modules 文件夾並使用來自 nodejs.org 的安裝程序重新安裝 node.js 來修復它,該安裝程序附帶 npm
之后我運行rm -r noode_modules
刪除重命名的 node_modules 副本
不確定刪除文件夾是否足夠也許我應該重新安裝所有舊軟件包以覆蓋我之前擁有的任何內容,然后使用npm uninstall
將其刪除以清理它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.