Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the version of an installed npm package

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?

like image 388
Laurent Couvidou Avatar asked Jun 10 '12 20:06

Laurent Couvidou


People also ask

Which command is used to determine the version of npm installed?

npm view <package> version - returns the latest available version on the package. npm list --depth=0 - returns versions of all installed modules without dependencies.

How do you check the version of a package in react?

The easiest and shorted way to check the React. js app version is to check it inside the package. json file under the dependencies section.


2 Answers

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:

projectName@projectVersion /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.

like image 75
TheHippo Avatar answered Oct 13 '22 19:10

TheHippo


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 if you have installed a lot of packages.

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

like image 25
Patrik Affentranger Avatar answered Oct 13 '22 18:10

Patrik Affentranger