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

相关推荐
曼巴UE51 小时前
UE FString, FName ,FText 三者转换,再次学习,官方文档理解
服务器·前端·javascript
行走的陀螺仪2 小时前
高级前端 Input 公共组件设计方案(Vue3 + TypeScript)
前端·javascript·typescript·vue·组件设计方案
一颗不甘坠落的流星2 小时前
【Antd】基于 Upload 组件,导入Json文件并转换为Json数据
前端·javascript·json
程序员爱钓鱼2 小时前
Node.js 编程实战:路由处理原理与实践
后端·node.js·trae
LYFlied2 小时前
Vue2 与 Vue3 虚拟DOM更新原理深度解析
前端·javascript·vue.js·虚拟dom
Lucky_Turtle2 小时前
【Node】npm install报错npm error Cannot read properties of null (reading ‘matches‘)
前端·npm·node.js
小飞侠在吗3 小时前
vue shallowRef 与 shallowReacitive
前端·javascript·vue.js
惜分飞3 小时前
sql server 事务日志备份异常恢复案例---惜分飞
前端·数据库·php
GISer_Jing4 小时前
WebGL实例化渲染:性能提升策略
前端·javascript·webgl