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 publishcommand publishes the package and gives a tag oflatestto the version in thepackage.json, overwriting the lastslatesttag version. - By default, the
npm installcommand installs the package version that has thelatesttag.