内源 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原文地址

相关推荐
老前端的功夫1 天前
Vue 3 性能深度解析:从架构革新到运行时的全面优化
javascript·vue.js·架构
天天扭码1 天前
如何实现流式输出?一篇文章手把手教你!
前端·aigc·ai编程
前端 贾公子1 天前
vue移动端适配方案 === postcss-px-to-viewport
前端·javascript·html
GISer_Jing1 天前
AI营销增长:4大核心能力+前端落地指南
前端·javascript·人工智能
GSDjisidi1 天前
东京IT软件会社-(株)GSD|多种技术栈募集,高度人才+20分
开发语言·面试·职场和发展
明远湖之鱼1 天前
一种基于 Service Worker 的渐进式渲染方案的基本原理
前端
前端小端长1 天前
Vue 中 keep-alive 组件的原理与实践详解
前端·vue.js·spring
FeelTouch Labs1 天前
Nginx核心架构设计
运维·前端·nginx
雪球工程师团队1 天前
别再“苦力”写后台,Spec Coding “跑” 起来
前端·ai编程