Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @11ty/dependency-tree with all npm packages installed. Try it out:

var dependencyTree = require("@11ty/dependency-tree")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@11ty/dependency-tree v1.0.0

Finds all JavaScript require dependencies from a filename.


Returns an unordered array of local paths to dependencies of a node JavaScript file (everything it or any of its dependencies requires).

Reduced feature (faster) alternative to the dependency-tree package that only works with stock node JS. This is used by Eleventy to find dependencies of a JavaScript file to watch for changes to re-run Eleventy’s build.


npm install --save-dev @11ty/dependency-tree


  • Ignores node_modules
  • Ignores Node’s built-ins (e.g. path)
  • Handles circular dependencies (Node does this too)


// my-file.js

// if my-local-dependency.js has dependencies, it will include those too
const test = require("./my-local-dependency.js");

// ignored, is a built-in
const path = require("path");
const DependencyTree = require("@11ty/dependency-tree");

// returns ["./my-local-dependency.js"]


const DependencyTree = require("@11ty/dependency-tree");

DependencyTree("./this-does-not-exist.js"); // throws an error

DependencyTree("./this-does-not-exist.js", { allowNotFound: true });
// returns []


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free