There are times when we want to be able to publish pre-release (ala SNAPSHOT
in maven terminology) versions of NPM packages to the NPM registry. We want to do this so as to provide these pre-release versions to CI builds of other dependant components etc. But what we do NOT want is for these pre-release packages to be unknowingly installed by someone that simply runs npm install <packagename>
(i.e. does not specify an @<version>
suffix).
Here are the key things you need to understand in order to be able to publish pre-release versons of packages:
- By default, the
npm publish
command publishes the package and gives a tag oflatest
to the version in thepackage.json
, overwriting the lastslatest
tag version. - By default, the
npm install
command installs the package version that has thelatest
tag.