Advertisement
Advertisement


Find the version of an installed npm package


Question

How to find the version of an installed node.js/npm package?

This prints the version of npm itself:

npm -v <package-name>

This prints a cryptic error:

npm version <package-name>

This prints the package version on the registry (i.e. the latest version available):

npm view <package-name> version

How do I get the installed version?

2014/08/13
1
2279
8/13/2014 12:31:29 PM

Accepted Answer

npm list for local packages or npm list -g for globally installed packages.

You can find the version of a specific package by passing its name as an argument. For example, npm list grunt will result in:

[email protected] /path/to/project/folder
└── [email protected]

Alternatively, you can just run npm list without passing a package name as an argument to see the versions of all your packages:

├─┬ [email protected] 
│ └── [email protected] 
├── [email protected] 
├── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
└── [email protected] 

You can also add --depth=0 argument to list installed packages without their dependencies.

2019/12/10
2666
12/10/2019 9:11:28 PM

Another quick way of finding out what packages are installed locally and without their dependencies is to use:

npm list --depth=0

Which gives you something like

├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Obviously, the same can be done globally with npm list -g --depth=0.

This method is clearer in case you have installed a lot of packages.

To find out which packages need to be updated, you can use npm outdated -g --depth=0.

2017/05/25

npm view <package> version - returns the latest available version on the package.

npm list --depth=0 - returns versions of all installed modules without dependencies.

npm list - returns versions of all modules and dependencies.

And lastly to get node version: node -v

2014/11/21

npm info YOUR_PACKAGE version

e.g.

npm info grunt version
0.4.5
2015/06/24

I just used

npm list | grep <package name>

and it worked great

On windows run:

npm list | find <package name>

In PowerShell run:

npm list | sls <package name>
2019/05/03

From the root of the package do:

node -p "require('./package.json').version"

EDIT: (so you need to cd into the module's home directory if you are not already there. If you have installed the module with npm install, then it will be under node_modules/<module_name>)

EDIT 2: updated as per answer from @jeff-dickey

2017/07/06