npm-tree

0.0.3 • Public • Published

npm-tree

Visualize the dependency tree of a given npm module.

Install:

$ sudo npm i -g npm-tree

CLI Usage

$ npm-tree express

CLI Output

accepts
  mime-types
    mime-db
  negotiator
buffer-crc32
debug
  ms
depd
escape-html
finalhandler
  debug
    ms
  escape-html
media-typer
methods
parseurl
path-to-regexp
proxy-addr
  ipaddr.js
qs
range-parser
send
  debug
    ms
  depd
  destroy
  escape-html
  fresh
  mime
  ms
  on-finished
    ee-first
  range-parser
serve-static
  escape-html
  parseurl
  send
    debug
      ms
    depd
    destroy
    escape-html
    fresh
    mime
    ms
    on-finished
      ee-first
    range-parser
  utils-merge
type-is
  media-typer
  mime-types
    mime-db
vary
cookie
fresh
cookie-signature
merge-descriptors
utils-merge

API Usage

require('npm-tree')('express', function(err, result){
  console.log(JSON.stringify(result, null, '  '));
});

Which will output:

{
  "accepts": {
    "mime-types": {
      "mime-db": {}
    },
    "negotiator": {}
  },
  "buffer-crc32": {},
  "debug": {
    "ms": {}
  },
  "depd": {},
  "escape-html": {},
  "finalhandler": {
    "debug": {
      "ms": {}
    },
    "escape-html": {}
  },
  "media-typer": {},
  "methods": {},
  "parseurl": {},
  "path-to-regexp": {},
  "proxy-addr": {
    "ipaddr.js": {}
  },
  "qs": {},
  "range-parser": {},
  "send": {
    "debug": {
      "ms": {}
    },
    "depd": {},
    "destroy": {},
    "escape-html": {},
    "fresh": {},
    "mime": {},
    "ms": {},
    "on-finished": {
      "ee-first": {}
    },
    "range-parser": {}
  },
  "serve-static": {
    "escape-html": {},
    "parseurl": {},
    "send": {
      "debug": {
        "ms": {}
      },
      "depd": {},
      "destroy": {},
      "escape-html": {},
      "fresh": {},
      "mime": {},
      "ms": {},
      "on-finished": {
        "ee-first": {}
      },
      "range-parser": {}
    },
    "utils-merge": {}
  },
  "type-is": {
    "media-typer": {},
    "mime-types": {
      "mime-db": {}
    }
  },
  "vary": {},
  "cookie": {},
  "fresh": {},
  "cookie-signature": {},
  "merge-descriptors": {},
  "utils-merge": {}
}

Programmatically getting console output

You can also simulate the console output by using the module function's exported stringify method:

npmTree = require('npm-tree');
npmTree('express', function(err, results){
  console.log(npmTree.stringify(results));
});

Limitations

While you can fetch a particular version of a library, like so:

$ npm-tree express@1.0.0

Keep in mind that npm-tree will only fetch the latest version of each of those dependencies, which will obviously diverge from whatever is specified by the package.json of the parent dependency.

Dependencies (4)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i npm-tree

    Weekly Downloads

    2

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • dustin.tinney
    • mike.testdouble
    • searls