惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
NISL@THU
NISL@THU
T
Tor Project blog
T
Tenable Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Privacy International News Feed
Cyberwarzone
Cyberwarzone
Project Zero
Project Zero
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
O
OpenAI News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
美团技术团队
Hugging Face - Blog
Hugging Face - Blog
V2EX - 技术
V2EX - 技术
H
Help Net Security
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
Forbes - Security
Forbes - Security
人人都是产品经理
人人都是产品经理
U
Unit 42
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
D
Docker
I
InfoQ
Schneier on Security
Schneier on Security
K
Kaspersky official blog
罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Security Affairs
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
雷峰网
雷峰网
G
GRAHAM CLULEY
Cloudbric
Cloudbric
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog
AI
AI
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
博客园_首页
T
Threat Research - Cisco Blogs
S
Secure Thoughts
有赞技术团队
有赞技术团队

Claude's Blog

浅谈 npm 依赖治理 记录 Got(Node.js) 代理 HTTP 请求的坑 如何管理桌面窗口 SSR 页面 CDN 缓存实践 从 is-promise 事件我们可以学到什么 从 Vimium 到 qutebrowser Verdaccio 性能优化:单机 Cluster 让 npm install 不使用缓存的方法 Verdaccio 性能优化:代理分流 Verdaccio 性能优化:上游路径转发 CSAPP DataLab 题解 不靠谱的 Egg.js 框架开发指南 如何解决 Debian 系 Elastic apm-server 7.x 启动失败 Hexo NexT 主题升级 7.4 From Journeyman to Master Mac 上移除 EasyConnect 常驻后台进程 Nginx SWRR 算法解读 记一次 Node.js 进程挂起的 BUG 追踪 警惕 Travis CI 的 npm 缓存
分享一个 npm dist-tag 的冷知识
Post author: Claude Ray · 2020-04-29 · via Claude's Blog

dist-tag 是广为 npm 包开发者所熟知的属性,如果不是今天碰到一个有趣的问题,我根本没想过拉它出来玩。

为了照顾不曾了解 dist-tag 的用户,我先用一句话介绍 —— dist-tag 是 npm 版本号的命名空间,而 latest 则是默认的命名空间。想必大家不会陌生 npm install <name>@latest 这样的用法吧。

更重要的是,除非 package.json 中有所指定,所有安装默认在 latest 空间下匹配版本号。而处在 latest 空间时,也不会去名为 beta 的 dist-tag 下查找版本号。

那么问题来了!设想一个 npm 包首次发布就使用 beta 作为 dist-tag,它可以被 npm install <name> 安装吗?

答案是肯定的。

我还发布了一个空白的 npm beta 包作为验证。

publish

install

明明 beta 和 latest 属于不同的命名空间,为啥这里用 latest 就把 beta 装了?

原因很简单,npm 服务端在初始化一个包时,不论发布者使用了什么 dist-tag,都会同时把它添加到 latest 上。这的确是个不成文的 feature,甚至 Verdaccio 等私服方案也按此逻辑来实现了。

为了不污染 npm 环境(或承接相应的骂名),上面测试发布的包已经被笔者下架了 :P