X

How to find the version of a globally installed NPM package

Sometimes, you really want to know the version of a globally installed NPM package. That’s the position I found myself in this morning. Googling didn’t help me much. Most of the answers I found just didn’t answer my question.

Here what you need to know. If you want to see the version of a globally installed NPM package, run this:

npm ls -g package-name --depth 0

Replace package-name with the name of whatever package you’re looking for.

In most cases, adding --depth 0 isn’t necessary. But in rare cases, the global package you’re searching for is also a dependency of other globally installed packages. When this happens, you’ll see the package you want, but you’ll also see a partial dependency tree of all of the packages that use the package you’re searching for.

Adding --depth 0 eliminates this problem. Feel free to leave that part out and only add it if you need it.

Ryan Peden: