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

原文地址:https://www.cnblogs.com/daaasheng/p/12205779.html