npm tag handling
npm registries support tags, which are string aliases for package
versions. You can use tags to provide an alias instead of using version numbers. For
example, you have a project with multiple streams of development and you use a different
tag for each stream (for example, stable
, beta
, dev
,
canary
). For more information, see dist-tag
By default, npm uses the latest
tag to identify the current version of a
package. npm install
(without
pkg
@
or
version
@
specifier) installs the latest tag.
Typically, projects only use the latest tag for stable release versions. Other tags are
used for unstable or prerelease versions. tag
Editing tags with the npm client
The three npm dist-tag
commands (add
, rm
,
and ls
) function the same way in CodeCatalyst package repositories as they
function in the default npm
registry
npm tags and upstream repositories
When npm
requests the tags for a package and versions of that package are
also present in an upstream repository, CodeCatalyst merges the tags before returning them to the
client. For example, a repository named R
has an upstream repository named U
.
The following table shows the tags for a package named web-helper
that's present in both
repositories.
Repository | Package name | Package tags |
---|---|---|
R |
|
latest (alias for version 1.0.0) |
U |
|
alpha (alias for version 1.0.1) |
In this case, when the npm client fetches the tags for the web-helper
package from repository R
, it receives both the latest and
alpha tags. The versions the tags point to won't change.
When the same tag is present on the same package in both the upstream and local repository, CodeCatalyst uses the tag that was last updated. For example, suppose that the tags on webhelper have been modified to look like the following.
Repository | Package name | Package tags | Last updated |
---|---|---|---|
R |
|
latest (alias for version 1.0.0) |
January 1, 2023 |
U |
|
latest (alias for version 1.0.1) |
June 1, 2023 |
In this case, when the npm client fetches the tags for package
web-helper from repository R
, the latest tag
will alias the version 1.0.1 because it was updated last. This makes it easy to consume new package versions in an upstream repository
that are not yet present in a local repository by running npm
update
.