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

optimize-deps

v0.1.1

Published

Create a minimized node_modules directory from the files used by Node.js entrypoints.

Readme

optimize-deps

Create a smaller node_modules directory for the JavaScript files your Node.js app actually uses.

npx optimize-deps src/main.js src/second.js src/mydir

optimize-deps accepts JavaScript files and directories. Files are verified before tracing. Directories are walked recursively and .js, .mjs, and .cjs files are added as entrypoints, while node_modules, .git, and the output directory are skipped.

The CLI uses @vercel/nft to trace runtime dependencies, then copies only traced root node_modules/* entries into node_modules_optimized.

Each run reports the approximate node_modules size before optimization, the optimized size after tracing, and the estimated savings:

Approx node_modules size: 10.4 MB before -> 1.4 MB after (saved 9.1 MB, 86.9%)

Options

optimize-deps [options] <js-file-or-directory...>

--replace                 Replace node_modules with the optimized output
--exports-only            Pass exportsOnly: true to @vercel/nft
--ignore <pattern>        Ignore pattern passed to @vercel/nft (repeatable)
--paths <alias=target>    Resolution path mapping passed to @vercel/nft (repeatable)
--output <dir>            Output directory (default: node_modules_optimized)
--dry-run                 Trace and report without writing files
--verbose                 Print entry files and NFT warnings

Examples:

optimize-deps src/main.js src/workers
optimize-deps --exports-only --ignore "node_modules/pkg/test/**" src/main.js
optimize-deps --paths "utils/=src/utils/" src/main.js
optimize-deps --replace src/main.js

With --replace, the existing node_modules directory is first moved to a temporary backup. The optimized directory is then renamed to node_modules, and the backup is deleted only after the rename succeeds.

In Docker/overlayfs builds, renaming a node_modules directory created in an earlier layer can fail with EXDEV: cross-device link not permitted. optimize-deps handles that by falling back to a copy-and-remove move that preserves file modes and symlinks.