簡體   English   中英

將我的 npm 從版本 6 升級到版本 7(節點版本為 10)后,我無法為某些項目安裝依賴項

[英]After Upgrading my npm from version 6 to version 7 (node version was 10) I cant install dependencies for some projects

我在我的系統中安裝了節點版本 10,在將我的 npm 從版本 6 升級到版本 7 之后,我無法安裝依賴項,並且出現錯誤,所以我不得不將我的節點降級到 6,( npm cinpm i失敗了)我正在測試的項目是這樣的:

https://github.com/Giveth/feathers-giveth

錯誤是這樣的:

npm ERR! code 128
npm ERR! git dep preparation failed
npm ERR! command /Users/username/.nvm/versions/node/v10.23.0/bin/node /Users/username/.nvm/versions/node/v10.23.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/username/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code 128
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command git clone --mirror -q ssh://git@github.com/gulpjs/gulp.git /Users/renjer/.npm/_cacache/_cacache/tmp/git-clone-dfb83c15/.git
npm ERR! npm ERR! fatal: destination path '/Users/username/.npm/_cacache/_cacache/tmp/git-clone-dfb83c15/.git' already exists and is not an empty directory.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /Users/username/.npm/_cacache/_logs/2021-02-18T16_18_35_855Z-debug.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/username/.npm/_logs/2021-02-18T16_20_15_536Z-debug.log

這個問題一般是因為如果你只升級系統的node版本,有一些包和依賴是按照那個版本安裝的。

這是一個手動過程,但您必須根據該版本安裝 package。

例如 (package.json):在您的節點 6 版本中,您有一些 package:

"xyz":^1.2.3

已安裝 package 及其與節點 6 一起使用的依賴項,從您的 package.json 中手動刪除 package 並像手動安裝一樣

npm install xyz

然后您可能會注意到版本升級,例如:

"xyz":^4.5.6

對你的每個包裹都這樣做,你的問題可能就會消失。 這就是我用來解決該問題的方法。

您還可以將所有軟件包升級到其最新版本,但是...如果您有很多軟件包並且有人不工作,您將不知道哪個失敗了,您將單獨檢查它。

也許(在寫這個答案的時候)如果你使用的是 Node 10,最新的軟件包版本也不會工作,因為該版本可以修復以與 Node 16(目前的 LTS(長期支持)版本)一起使用寫這個答案)。

如果您還沒有這樣做,我建議您不斷將您的系統升級到某個未棄用的 LTS 版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM