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

相关推荐
!执行几秒前
Web3 前端与合约交互
前端·web3·1024程序员节
潘小安5 分钟前
跟着 AI 学(二)- Quill 接入速通
前端
十里-17 分钟前
在 Vue2 中为 Element-UI 的 el-dialog 添加拖拽功能
前端·vue.js·ui
shada22 分钟前
从Google Chrome商店下载CRX文件
前端·chrome
左耳咚37 分钟前
项目开发中从补码到精度丢失的陷阱
前端·javascript·面试
黑云压城After1 小时前
vue2实现图片自定义裁剪功能(uniapp)
java·前端·javascript
芙蓉王真的好11 小时前
NestJS API 提示信息规范:让日志与前端提示保持一致的方法
前端·状态模式
dwedwswd1 小时前
技术速递|从 0 到 1:用 Playwright MCP 搭配 GitHub Copilot 搭建 Web 应用调试环境
前端·github·copilot
2501_938774291 小时前
Leaflet 弹出窗实现:Spring Boot 传递省级旅游口号信息的前端展示逻辑
前端·spring boot·旅游
meichaoWen1 小时前
【CSS】CSS 面试知多少
前端·css