How to check the version of an installed npm package
In this tutorial, we are going to learn about how to check the version of a installed npm package and its dependencies.
Installed version of all packages
To check the installed version of all npm packages in your project, you can use the npm list
command.
npm list
Output:
├─┬ express@4.17.1
│ ├─┬ accepts@1.3.7
│ │ ├─┬ mime-types@2.1.26
│ │ │ └── mime-db@1.43.0
│ │ └── negotiator@0.6.2
│ ├── array-flatten@1.1.1
│ ├─┬ body-parser@1.19.0
│ │ ├── bytes@3.1.0
│ │ ├── content-type@1.0.4 deduped
│ │ ├── debug@2.6.9 deduped
│ │ ├── depd@1.1.2 deduped
│ │ ├─┬ http-errors@1.7.2
│ │ │ ├── depd@1.1.2 deduped
│ │ │ ├── inherits@2.0.3
│ │ │ ├── setprototypeof@1.1.1 deduped
│ │ │ ├── statuses@1.5.0 deduped
│ │ │ └── toidentifier@1.0.0
│ │ ├─┬ iconv-lite@0.4.24
│ │ │ └── safer-buffer@2.1.2
│ │ ├── on-finished@2.3.0 deduped
│ │ ├── qs@6.7.0 deduped
Note: The npm list command doesn’t only show the installed version of packages, but also their dependencies (version).
For globally installed packages, you can use the npm list -g
command.
Installed version of a particular package
To check the installed version of a particular package, you can use the npm list
command by specifying a package name.
Example:
npm list express
Output:
node-project@1.0.0 /Users/saigowtham/Desktop/node-project
└── express@4.17.1
If you want to check the latest version of a package available in npm repository, you can use
the npm view package-name version
command.
npm view express version
Output:
4.17.1