

分享一个 npm dist-tag 的冷知识
source link: http://claude-ray.com/2020/04/29/npm-initial-publish-with-beta-tag/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

分享一个 npm dist-tag 的冷知识
Posted on
2020-04-29 In Node.js
Disqus:
0 Comments
Symbols count in article:
343
Reading time ≈
1 mins.
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 包作为验证。
明明 beta 和 latest 属于不同的命名空间,为啥这里用 latest 就把 beta 装了?
原因很简单,npm 服务端在初始化一个包时,不论发布者使用了什么 dist-tag,都会同时把它添加到 latest 上。这的确是个不成文的 feature,甚至 Verdaccio 等私服方案也按此逻辑来实现了。
为了不污染 npm 环境(或承接相应的骂名),上面测试发布的包已经被笔者下架了 :P
- Post author: Claude Ray
- Post link: http://claude-ray.com/2020/04/29/npm-initial-publish-with-beta-tag/
- Copyright Notice: All articles in this blog are licensed under BY-NC-SA unless stating additionally.
Recommend
-
49
Programming Models for Distributed Computation Source repo for the book that I and my students in my course at Northeastern University, CS7680 Special Topics in Computing...
-
14
Utilize PGO for rustc linux dist builds by Mark-Simulacrum · Pull Request #80262 · rust-lang/rust · GitHub This implements support for applying PGO to the rustc compilation step (not standard library or any tooling, including...
-
9
Distributed sccache (sccache-dist)¶ sccache is a ccache-like...
-
9
egg-init/lib/init_command.js我们看下对应源码,注意很详细。'use strict'; const os = require('os'); const assert = require('assert'); const fs = require('fs'); const path = require('path'); const urllib = require('urlli...
-
11
PDF.js PDF.js is a Portable Document Format (PDF) library that is built with HTML5. Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs. This is a pre-built version of the PDF.j...
-
6
【包管理器】一个由第三方包管理器与npm冲突导致的bug这是一个神奇的bug,也是一个花费时间的bug哈哈哈。当遇到这种类型的bug确实会出现挺难下手的尴尬之处。 下面便是我对这个bug的折磨历程,对,我对它的折磨! 项目背景与问题分析...
-
17
OpenWrt-dist LuCI APP 列表 Name Depends Description luci-app-chinadns openwrt-chinadns LuCI Support for ChinaDNS luci-app-dns-forwarder
-
18
rampart-dist-1.4-src.zipHome rampart-dist-1.4-src.zip rampart-dist-1.4-src.zip
-
2
本文是 Element 的组件源码学习系列。 项目源码:ElemeFE/element | GitHub,Tag:v2.13.0 Tag 组件使用文档:T...
-
4
Release Engineering Is Exhausting So Here's cargo-dist by Gankra, 1 February 2023 |
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK