内源 npm 无法同步官方 npm 解法

内源的 NPM 通常通过 npm config set registry http://内网 全局配置了内源 NPM,采用 T+1 进行官方 NPM 的缓存同步。

但可能会存在没有 sync 机制的场景,当依赖的一个外部包发了新版本是无法立即消费的。

可以采用以下方式修正。

1. scope 限制 registry

使用 scope 直接将非 @公司前缀 的包全部走官方源,来解决不同步的问题。

bash 复制代码
npm config delete registry -g
npm config delete registry

npm config set @公司前缀:registry=http://内网

2. scope + cnpm 提速

如果官方源速度慢,可以注册 cnpm,且 cnpm 是支持 sync 的。

bash 复制代码
npm config delete registry -g
npm config delete registry

npm config set @公司前缀:registry=http://内网
npm config set registry https://registry.npmmirror.com

或者直接放在 .npmrc 里:

bash 复制代码
registry=https://registry.npmmirror.com
@公司前缀:registry=http://内网

需要同部包,直接:

bash 复制代码
cnpm sync xxx

微信搜索"好朋友乐平"关注公众号。

github原文地址

相关推荐
liliangcsdn几秒前
mac mlx大模型框架的安装和使用
java·前端·人工智能·python·macos
CssHero4 分钟前
基于vue3完成领域模型架构建设
前端
PanZonghui7 分钟前
用项目说话:我的React博客构建成果与经验复盘
前端·react.js·typescript
挽淚9 分钟前
JavaScript 数组详解:从入门到精通
javascript
言兴10 分钟前
教你如何理解useContext加上useReducer
前端·javascript·面试
sunbyte13 分钟前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | GoodCheapFast(Good - Cheap - Fast三选二开关)
前端·javascript·css·vue.js·tailwindcss
7ayl14 分钟前
TCP 连接终止:四次挥手
面试
前端的日常15 分钟前
网页视频录制新技巧,代码实现超简单!
前端
前端的日常16 分钟前
什么是 TypeScript 中的泛型?请给出一个使用泛型的示例。
前端
今禾17 分钟前
一行代码引发的血案:new Array(5) 到底发生了什么?
前端·javascript·算法