Get the Latest Version of an npm Package - without downloading and installing it

23 Oct 2015

npm is big and getting bigger. It is an extremely powerful package manager that makes the usage of JavaScript modules easy and delightful.

There may be times when you want to see if there is a currently higher version of a package that is available. There are a couple of ways to do this. You might default to just going to the website (www.npmjs.com). But the beauty of npm is that the command line interface gives us all the power to do what we need.

Take this example. Say you want to see if there is a current update for npm itself. As you may already know, you can update npm by running…

npm install -g npm

That’s a bit of a brute-force check, as you’ll find out after the update what the latest version is (if there is even an update available). But what would you do if you want to just see if there is a newer version than what you are currently running?

Simple dump your current version…

npm -v

Or in the instance that you’re looking for your current version of another package (not npm itself), you can run this for local packages…

npm list

And this for global packages…

npm list -g

And then pull the info for the latest version…

npm view npm dist-tags.latest

At this point, you can see what your current package (npm in this case) version is, and what the latest published package is.

Enjoy!