How do I install the latest available version of an npm package? '@latest' sure doesn't fetch the latest - I assume it means the latest stable or something.
I've been using a hack for a while because I cannot seem to find any info on this:
npm i extract-text-webpack-plugin@X
The 'X' causes it to fail and dump all possible versions where I then copy and paste the correct one instead of the 'X'. Kinda ridiculous.
I've tried 3rd party packages like 'latest-version' but they all fail to get the very latest version.
There doesn't seem to be an official to do this. For example at the time of writing the latest version of extract-text-webpack-plugin is 2.0.0-beta.4. However doing:
npm i extract-text-webpack-plugin@latest
Will install '1.0.1'
I can see the latest version by doing
npm info pkg versions --json (without --json it will cut off when there are many versions)
For lack of an actual tool I guess its going to be some grep work.
Use
npm update
as long as you have the package installed:Version
1.0.1
is the 'latest' version of that package - published to the npm registry at least (tagged aslatest
)From the docs for
cli/dist-tag
. Emphasis mine.If you want the beta releases, then install from GitHub, or use the tags explicitly.
This is made pretty clear by reading the manual.
Even more clear:
latest
is an implicit tag, attached to any published version of a package that was not published with an explicit tag (--tag
).Installing
xyz@latest
simply looks up the release tagged aslatest
in the registry. In the case of this package, that's release1.0.1
. That's it. There's nothing special going on here.@latest
does not pull the most recent version published tonpm
The versions listed as betas were tagged differently. Obviously none of them were tagged as
latest
, so trying to use@latest
to get one is pointless.From the registry:
Again, use the GitHub releases for the bleeding edge, or use the versions/tags explicitly.
Here you go, made especially for you:
recent-version
recent-version-cli
Condense this into a shell script, and you're good to go: