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 (ie the latest version available):

npm view <package-name> version

How do I get the installed version ?


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
└── grunt@0.4.1

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

├─┬ cli-color@0.1.6 
│ └── es5-ext@0.7.1 
├── coffee-script@1.3.3 
├── less@1.3.0 
├─┬ sentry@0.1.2 
│ ├── file@0.2.1 
│ └── underscore@1.3.3 
└── uglify-js@1.2.6 

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

├── bower@0.8.6
├── grunt@0.4.1
├── grunt-bower-requirejs@0.4.3
├── grunt-contrib-clean@0.4.1
├── grunt-contrib-coffee@0.7.0
├── grunt-contrib-copy@0.4.1
├── grunt-contrib-imagemin@0.1.4
├── grunt-contrib-jshint@0.1.1
├── grunt-contrib-livereload@0.1.2
├── grunt-contrib-requirejs@0.4.1
├── grunt-regarde@0.1.1
└── grunt-svgmin@0.1.0

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 .


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

链接地址: http://www.djcxy.com/p/18052.html

上一篇: Grunt,NPM和Bower之间的区别(package.json vs bower.json)

下一篇: 查找已安装的npm软件包的版本