Last Updated: February 25, 2016
·
1.333K
· DamonOehlman

npm view is your friend

To check on NPM packages I usually catch myself heading over to the npmjs.org website and looking at the package information. For instance, if I want to see what the latest information for something like tako is I would go to https://npmjs.org/package/tako.

While this is good and fine, it is definitely more efficient to simply type npm view <packagename> into the console to get the raw information that is stored in registry.npmjs.org.

For instance, running:

npm view tako

Provides the following helpful output:

{ name: 'tako',
  description: 'Functional web framework.',
  'dist-tags': { latest: '0.3.0' },
  versions: 
   [ '0.0.1',
     '0.2.0',
     '0.2.1',
     '0.2.2',
     '0.2.3',
     '0.2.4',
     '0.2.5',
     '0.3.0' ],
  maintainers: 'maxogden <max@maxogden.com>',
  time: 
   { '0.0.1': '2012-02-05T22:43:37.591Z',
     '0.2.0': '2012-02-27T21:06:44.229Z',
     '0.2.1': '2012-03-12T07:42:48.709Z',
     '0.2.2': '2012-03-12T07:59:58.136Z',
     '0.2.3': '2012-04-16T20:02:34.872Z',
     '0.2.4': '2012-04-16T20:10:37.278Z',
     '0.2.5': '2012-04-17T23:37:59.930Z',
     '0.3.0': '2012-05-08T21:31:42.248Z' },
  author: 'Mikeal Rogers <mikeal.rogers@gmail.com>',
  repository: 
   { type: 'git',
     url: 'git://github.com/mikeal/tako.git' },
  users: {},
  tags: 
   [ 'http',
     'simple',
     'util',
     'utility',
     'web',
     'framework',
     'webframework' ],
  version: '0.3.0',
  bugs: { url: 'http://github.com/mikeal/tako/issues' },
  main: './index.html',
  dependencies: { filed: '>= 0.0.6', mapleTree: '*' },
  devDependencies: { request: '2.9.x' },
  scripts: { test: 'node tests/run.js' },
  optionalDependencies: {},
  engines: { node: '*' },
  dist: 
   { shasum: '5e417b4d156d4a33563207211b242ce313f6ab37',
     tarball: 'http://registry.npmjs.org/tako/-/tako-0.3.0.tgz' },
  directories: {} }

The major advantage of using the npm view approach rather than the npmjs.org website is that the information you are receiving is not cached, and you can be sure that whatever is there is up to date and accurate.

Extra Coolness - Filtering Output

Thanks heaps to @sindresorhus for an extra pointer that you can filter out only particular information when running npm view. For instance running:

npm view tako version

Will report the version, or running:

npm view tako dependencies

Would provide just the dependency information. You can even go further and extra nested properties information:

npm view tako repository.url

In short, npm view is definitely one of the power tools within NPM and I for one don't make enough use of it...

Info Alias

While the actual command is view I usually use the info alias, which produces the same output.

Full Documentation

For full documentation on the view command, check out the following url:

https://npmjs.org/doc/view.html