npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

get-dep-tree

v3.1.0

Published

Use npm's Arborist to get a dependency tree for a package.

Readme

get-dep-tree Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Use npm's Arborist to get a dependency tree for a package.

Example

const getDepTree = require('get-dep-tree');
const { Node } = require('@npmcli/arborist');
const assert = require('assert');

getDepTree().then((tree) => {
	assert.ok(tree instanceof Node);
});

API

getDepTree(mode, options = {})

Returns a Promise for an Arborist Node representing the root of the tree.

mode is one of:

  • 'actual': load the tree from node_modules on disk
  • 'virtual': load the tree from package-lock.json (a v1 lockfile is used to build an ideal tree)
  • 'ideal': build an ideal tree from package.json, using the registry
  • 'auto': 'actual' if path has a node_modules directory, otherwise 'virtual' if it has a package-lock.json, otherwise 'ideal'

options:

  • path: the package directory to load. Default: process.cwd()
  • dev: keep dev dependencies. Default: false
  • production: keep production dependencies; when false, only nodes needed by the dev hierarchy are kept (so with dev: false as well, every dependency is pruned). Default: true
  • peer: keep peer dependencies. Default: true
  • optional: keep optional dependencies. Default: true
  • fullMetadata: passed through to @npmcli/arborist and pacote, for registry fetches. Default: false. Note that @npmcli/arborist always fetches full manifests while building an ideal tree, that top-level nodes from a v1 lockfile are always given full manifests, and that 'actual' and 'virtual' modes otherwise do not fetch from the registry, so node.package only has what is on disk (see forceActual) or in the lockfile.
  • packumentCache: a Map to cache packuments in; share one across calls to avoid refetching. Default: a new Map
  • logger: a function called with progress messages. Default: console.log
  • forceActual: when loading from node_modules ('actual' mode, or 'auto' mode when node_modules exists), ignore the hidden lockfile (node_modules/.package-lock.json), so each node's package is its real package.json, rather than the subset of fields the hidden lockfile stores. Default: false
  • registry: the registry URL. Default: 'https://registry.npmjs.org/'
  • any other flattened npm config options (eg, cache, offline, or '//registry.example.com/:_authToken') are passed through to @npmcli/arborist and pacote. Note that .npmrc files are not read; use @npmcli/config to load and flatten them.

Pruning applies to every node in the tree, at any depth, based on arborist's dev, optional, devOptional, and peer flags. dev: false, peer: false, and optional: false use arborist's node.shouldOmit, the same check as npm install --omit=dev/--omit=peer/--omit=optional; so, for example, a dependency needed by both the dev and the optional hierarchies is only pruned when both dev and optional are false.