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

相关推荐
骇客野人8 分钟前
Java 前后端可部署落地架构方案
服务器·前端·微服务
OpenTiny社区14 分钟前
从开发到运行:OpenTiny NEXT 如何构建 Agent 时代的 Web 应用
前端·开源·ai编程·opentiny
feixing_fx20 分钟前
伪类与伪元素的魔法:纯 CSS 打造炫酷的按钮悬停特效
前端·css·css3
动恰客流统计20 分钟前
用客流数据优化门店排班:高峰不缺人、平峰不浪费的落地路径
大数据·前端·人工智能
广州山泉婚姻29 分钟前
前后端分离的核心优势
前端·后端
志尊宝30 分钟前
Vue3 零基础每日笔记(043):defineModel 与 defineExpose 的 TS 用法——3.4+ 新 API 进阶
前端·javascript·vue·html·vue3
洛兮银儿31 分钟前
前端页面引入cesium
前端·cesium
SEO_juper42 分钟前
2026年用Python分析网站访问日志:看清Googlebot和AI爬虫怎么爬你的站(附完整代码)
开发语言·前端·seo·独立站·谷歌优化
摸鱼仙人~43 分钟前
React 原理进阶:彻底理解 re-render、React.memo、useMemo 与 useCallback
前端·vue.js
IMPYLH1 小时前
HTML 的 <small> 元素
前端·网络·html