书接上回~
前言
由于种种原因,大家在使用 npm 或其他包管理工具时,都会更换其默认镜像源,例如:taobao 来提高效率。
虽然早在 2022年 时淘宝发布了更换镜像地址的公告,直至 2024/01/22 SSL 证书过期前服务都是可用的。
由于 npm 默认开启了 ssl 验证,你可以选择关闭该项服务(不推荐,仅建议使用内部源时)或者更换正确的镜像源。
方案
更换镜像源(推荐)
npm
查询源
npm get registry
设置源
# 国内 淘宝 镜像源
npm config set registry https://registry.npmmirror.com/
# 官方镜像源
npm config set registry https://registry.npmjs.org/
关闭 SSL 验证(不推荐)
理论设置 npm 的即可,pnpm 同理
# 关闭
npm config set strict-ssl false
# 恢复
npm config set strict-ssl true
查询 config
# npm 同理
pnpm config list
email=
home=https://npmmirror.com
prefix=/usr/local
registry=https://registry.npmjs.org/
regsitry=https://registry.npmjs.org/
strict-ssl=true
user-agent=pnpm/9.1.2 npm/? node/v20.10.0 darwin x64
























