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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dep-forest

v1.2.1

Published

`dep-forest`, aka "dependency-forest", is a tool for analyzing and visualizing the module dependencies in your JavaScript or TypeScript projects. Whether you're using ES Modules (`import`) or CommonJS (`require`), `dep-forest` helps you count and track ho

Downloads

12

Readme

Dep-Forest 🌲 🌲 🌲

dep-forest, aka "dependency-forest", is a tool for analyzing and visualizing the module dependencies in your JavaScript or TypeScript projects. Whether you're using ES Modules (import) or CommonJS (require), dep-forest helps you count and track how many dependencies your code relies on, including their nested dependencies.

Its name comes from the fact that we often think of file dependencies as a tree, or in some cases a forest. As the count of dependencies grows, so does the forest 🌲 🌲 🌲 and in many cases we want to know how many trees we're looking at. This is especially true if we start to see performance issues and want to know which files are most heavily relied on or pulled in as a part of an unexpected dependency tree.

Note: there are lots of other tools out there that provide similar functionality, but I wanted a lightweight tool that was easy to understand and extend. In the future additional features like visualizations or eslint-plugin integration are likely to be added - though there are no currently planned milestones.

Features

  • ESM & CommonJS Support: Tracks dependencies for both import and require statements.
  • Recursive Dependency Counting: Calculates the number of direct and indirect dependencies.
  • TypeScript Support: Works seamlessly with TypeScript files (.ts, .tsx).
  • File System Integration: Resolves local file imports and node_modules dependencies.
  • Customizable: Easily extendable to customize how dependencies are handled.

Installation

You can install the package via npm or yarn:

| NPM | Yarn | | --- | ---- | | npm install --save-dev dep-forest | yarn add -D dep-forest |

Usage

CLI Usage

dep-forest comes with a command-line interface that allows you to analyze your project files.

yarn dep-forest <entry-file>

For example when run against the examples in this repo:

yarn dep-forest ./examples/simple.js 
[dep-forest] Total dependencies for /dep-forest/examples/simple.js: 3
[dep-forest] >>> visited files: Set(2) {
  '/dep-forest/examples/simple.js',
  '/dep-forest/examples/simpleUtility.js'
}
[dep-forest] >>> dependencies: [
  'fs',
  'path',
  '/dep-forest/examples/simpleUtility.js'
]

As you can see this prints out a few things:

  • total count of dependencies
  • a list of files that were visited
  • a list of dependencies

Programmatic Usage

You can also use dep-forest programmatically in your own scripts:

const { calculateDependencies } = require('dep-forest');

const filePath = './examples/simple.js'; // Path to your entry file
const { dependencyCount, visited, dependencyPaths } = calculateDependencies(filePath);

console.log(`Total dependencies for ${filePath}: ${dependencyCount}`);

Supported File Types

  • JavaScript: .js, .mjs, .jsx
  • TypeScript: .ts, .tsx

Example Files

Example files can be found in the example directory. These will be added on to from time to time to showcase new features or bug fixes and are used for testing.

Contributing

Contributions welcome! Feel free to fork the repo, make changes, and submit a pull request. For larger changes, please open an issue first to discuss what you would like to change. Chances are it's all good - but it's always best to discuss before you put in the effort to implement something.