[英]Cant see npm version on ubuntu because of Error: Cannot find module 'semver'
我在我的機器上重新安裝了 ubuntu 並在安裝節點之后做出反應,npm,當我嘗試啟動舊項目並在啟動項目時遇到相同的錯誤時,以及當我嘗試查看 ZBB30E85411B546DF41296726AB4 的版本時。
node:internal/modules/cjs/loader:927
throw err;
^
Error: Cannot find module 'semver'
Require stack:
- /usr/share/npm/lib/utils/unsupported.js
- /usr/share/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/share/npm/lib/utils/unsupported.js',
'/usr/share/npm/bin/npm-cli.js'
]
}
我再次卸載並安裝了 npm 但沒有幫助
試試這個鏈接anotehr SO post
基本上他們正在做的是以下步驟:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --force node
brew install node
用相應的 package 管理器替換brew
一般不需要單獨安裝npm
。 npm
與node
捆綁在一起,捆綁的版本通常與您正在運行的node
版本一起使用。 如果您單獨安裝npm
,您將面臨安裝不兼容版本node
的風險。
所以卸載npm
。 看看您是否還有可用的npm
。 如果沒有,請卸載並重新安裝node
。 Do not install npm
separately (unless it is using npm
itself to update to a newer version of npm
with npm install -g npm
.)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.