How to identify the latest npm package version

You can use

npm_info_cmd.sh
npm info [package name] version | head -n1

to print just the latest package version, for example:

npm_info_example.sh
npm info @angular/cli version | head -n1

The head -n1 part is neccessary to suppress unwanted npm info messages. Just running the command without head -n1 :

npm_info_full.sh
npm info @angular/cli version

prints the following output:

npm_info_output.txt
12.2.6
npm notice 
npm notice New minor version of npm available! 7.21.1 -> 7.24.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.24.0
npm notice Run npm install -g [email protected] to update!
npm notice

I typically use the node:latest docker container instead of a local npm to find the latest version of an npm package:

docker_npm_command.sh
docker run -it --rm node:latest npm info meshcommander version | head -n1

At the time of writing this article, the command prints

npm_version_output.txt
0.9.0-d

 


Check out similar posts by category: NodeJS