项目中安装依赖时常见错误及解决方法

509 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

前言

在 clone 项目时都会先安装依赖,在这一环节都希望顺利安装完成,有时候难免会遇到一些错误导致依赖安装失败,下面就对一些项目中遇到的问题做下总结以及解决方法。

No matching version found for @handday/components@^0.0.18

在 clone 很久以前的项目时执行 npm install 时报错,提示以下错误:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for @handday/components@^0.0.18.
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! notarget
npm ERR! notarget It was specified as a dependency of 'wise_medical_pc'
npm ERR! notarget

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\10642\AppData\Roaming\npm-cache\_logs\2022-05-07T03_06_39_618Z-debug.log

一个依赖的安装失败会导致后续的依赖全部无法安装,所以需要解决以上依赖的错误,上述错误信息表示 @handday/components@^0.0.18 没有匹配的版本,去 npm 上看了下确实没有对应的版本:

QQ截图20220507111908.png

解决方法:

根据需求重新安装一下依赖的版本,这里我安装最新版本,然后再执行下 npm install 来安装所有依赖。