npm install異常解決


問題

操作系統: 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"
  }
},

分析

  1. 看問題應該是因為版本問題, 去npm官網確認, 此版本是存在的。

  2. 查看lock文件, 安裝地址不是標准地址。 wget ${下載地址}, 下載成功說明鏡像是沒有問題的。

  3. 嘗試移除lock文件后, 重新安裝其他庫出現相同錯誤提示。觀察相似之處, 兩個庫都是最新版本。

  4. npm install npm@latest -g更新npm為最新版本, 重新安裝依然失敗。

  5. npm config get registry發現是公司內部鏡像, 更新鏡像, 重新安裝成功。

最后解決方案

修改npm 鏡像npm config set registry https://registry.npmjs.org


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM