共计 1484 个字符,预计需要花费 4 分钟才能阅读完成。
前提:npm i 之后,安装依赖失败
【报错示例】
npm ERR! code ETARGET
npm ERR! notarget No matching version found for raphael@2.2.0-c.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
报错提示无法匹配依赖对应的版本号,导致下载失败。
【解决方案】
在了解 npm
语义版本控制及语义化版本号的表示后,得出解决方案。package-lock.json
文件中,找出安装失败的依赖所有版本号,在前面加 ^
、~
符号或者删除版本号。
依赖版本号表示:x.y.z
x 表示主版本,y 表示次版本,z 表示补丁版本
^
符号表示版本不升级,次版本、补丁版本升级到最新。^2.2.0 等价于 2.2.0 >= ^2.2.0~
符号只会升级补丁版本。例如:~2.2.0 等价于 2.2.0 >= ~2.2.0 删除版本号等于""
空符号表示更新到最新版本。
【解决示例】
1、加 ^ 符号
"node_modules/raphael": {
"version": "^2.2.0-c",
"license": "MIT",
"dependencies": {
"eve": "git://github.com/adobe-webplatform/eve.git#eef80ed"
}
},
...
"raphael": {
"version": "^2.2.0-c",
"requires": {
"eve": "git://github.com/adobe-webplatform/eve.git#eef80ed"
}
},
...
"tui-chart": {
"version": "3.11.3",
"requires": {
"core-js": "^3.6.4",
"raphael": "https://github.com/nhn/raphael.git#^2.2.0-c",
"tui-code-snippet": "^2.3.1"
},
"dependencies": {
"tui-code-snippet": {
"version": "2.3.3"
}
}
},
同理可得加 ~
符号…。
2、删除版本号
"node_modules/raphael": {
"version": "",
"license": "MIT",
"dependencies": {
"eve": "git://github.com/adobe-webplatform/eve.git#eef80ed"
}
},
...
"raphael": {
"version": "",
"requires": {
"eve": "git://github.com/adobe-webplatform/eve.git#eef80ed"
}
},
...
"tui-chart": {
"version": "3.11.3",
"requires": {
"core-js": "^3.6.4",
"raphael": "https://github.com/nhn/raphael.git",
"tui-code-snippet": "^2.3.1"
},
"dependencies": {
"tui-code-snippet": {
"version": "2.3.3"
}
}
},
原文地址: 【npm】拉取项目后,安装依赖报错怎么办?npm ERR! notarget No matching version found for…
正文完