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

推荐订阅源

The Hacker News
The Hacker News
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
L
LangChain Blog
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Full Disclosure
T
The Blog of Author Tim Ferriss
月光博客
月光博客
有赞技术团队
有赞技术团队
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
博客园 - Franky
B
Blog
博客园_首页
C
CERT Recently Published Vulnerability Notes
Hugging Face - Blog
Hugging Face - Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
I
Intezer
P
Proofpoint News Feed
博客园 - 叶小钗
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
Recorded Future
Recorded Future
NISL@THU
NISL@THU
A
Arctic Wolf
Know Your Adversary
Know Your Adversary
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
C
Cisco Blogs
大猫的无限游戏
大猫的无限游戏
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
Forbes - Security
Forbes - Security
Project Zero
Project Zero
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cisco Talos Blog
Cisco Talos Blog
D
Docker
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
人人都是产品经理
人人都是产品经理

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