問題
操作系統: centos7
node: v10.13.0
npm: v6.4.0
錯誤提示
npm ERR! code ETARGET
npm ERR! notarget No matching version found for echarts@4.6.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
pack-lock.json
"echarts": {
"version": "4.6.0",
"resolved": "https://mirrors.huaweicloud.com/repository/npm/echarts/-/echarts-4.6.0.tgz",
"integrity": "sha512-xKkcr6v9UVOSF+PMuj7Ngt3bnzLwN1sSXWCvpvX+jYb3mePYsZnABq7wGkPac/m0nV653uGHXoHK8DCKCprdNg==",
"requires": {
"zrender": "4.2.0"
}
},
分析
-
看問題應該是因為版本問題, 去npm官網確認, 此版本是存在的。
-
查看lock文件, 安裝地址不是標准地址。
wget ${下載地址}, 下載成功說明鏡像是沒有問題的。 -
嘗試移除lock文件后, 重新安裝其他庫出現相同錯誤提示。觀察相似之處, 兩個庫都是最新版本。
-
npm install npm@latest -g更新npm為最新版本, 重新安裝依然失敗。 -
npm config get registry發現是公司內部鏡像, 更新鏡像, 重新安裝成功。
最后解決方案
修改npm 鏡像npm config set registry https://registry.npmjs.org
