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

相关推荐
掘金一周4 分钟前
Flex 布局下文字省略不生效?原因其实很简单| 掘金一周 10.16
前端
你的电影很有趣5 分钟前
lesson72:Node.js 安全实战:Crypto-Js 4.2.0 与 Express 加密体系构建指南
javascript·安全·node.js
聪明的笨猪猪7 分钟前
Java 面试清单(含超通俗生活案例与深度理解)
java·经验分享·笔记·面试
Stringzhua9 分钟前
Vue的Axios介绍【9】
前端·javascript·vue.js
渣哥13 分钟前
从 READ_UNCOMMITTED 到 SERIALIZABLE:Spring 事务隔离级别全解析
javascript·后端·面试
云霄IT17 分钟前
绕过Frida检测反调试的一些办法
android·javascript
摸着石头过河的石头25 分钟前
JavaScript 垃圾收集:内存管理的艺术
前端·javascript
前端小崽子26 分钟前
🔥 踩坑实录:Fabric 在 Intel Iris Xe 显卡上 CPU 飙升 100%
前端
东华帝君30 分钟前
React Suspense组件
前端
siaikin31 分钟前
基于 Astro Starlight 的多框架文档
前端·vue.js·markdown