npm 安装踩坑

1 网络正常,但是以前的老项目安装依赖一直卡住无法安装?哪怕切换成淘宝镜像

解决办法:切换成yarn

(1)   npm i yarn -g


(2)   yarn init

(3)   yarn install

在安装的过程中发现:

[2/4] Fetching packages...
error marked@11.1.0: The engine "node" is incompatible with this module. Expected version ">= 18". Got "16.14.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

则还需要进行如下设置:

yarn config set ignore-engines true

此时可以正常安装。

2 在用yarn安装过程中报错:error Error: certificate has expired如何处理?

解决办法

(1)yarn config list 查看strcit-ssl是否默认是true

(2)更改该配置为false

yarn config set strict-ssl false

重新查看

yarn config list 如果为false则设置成功

 3 yarn安装过程中报错getaddrinfo ENOTFOUND如何处理?

这个问题多半是因为yarn设置的默认下载镜像地址是老版registry.nlark.com地址。我们可以把镜像改成淘宝的地址

yarn config set registry https://registry.npmmirror.com/

这样就可以了。我们可以把项目原本的yarn.lock文件删除,重新安装,因为设置了淘宝镜像,所以新生成的yarn.lock文件里的镜像全部成了淘宝的镜像地址,这样就不会报错getaddrinfo ENOTFOUND

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值