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

@starcart.com/optional-deps-validate

v1.0.0

Published

A CLI tool to detect missing optional dependencies in package-lock.json

Readme

optional-deps-validate

(note: this package is almost entirely written by AI)

Validate that all optional dependencies declared by installed packages are present in package-lock.json.

This is a workaround for this npm issue.

When using Node.js and npm, certain packages declare OS- or architecture-specific sub-dependencies in their optionalDependencies. However, sometimes npm can generate a partial package-lock.json that excludes some or all of those optional deps. This can lead to problems on other machines or CI when npm fails to install required platform packages.

optional-deps-validate is a CLI tool that scans your local node_modules and compares each installed package's optionalDependencies against your package-lock.json. If any are missing, it warns you and exits with a non-zero status code.

Installation

npm install -D @starcart.com/optional-deps-validate
# or
yarn add -D @starcart.com/optional-deps-validate
# or
pnpm add -D @starcart.com/optional-deps-validate

You can also install it globally:

npm install -g @starcart.com/optional-deps-validate
# or
yarn global add @starcart.com/optional-deps-validate
# or
pnpm add -g @starcart.com/optional-deps-validate

Then run it using:

npx @starcart.com/optional-deps-validate

Usage

Run the command in any project directory that has both a package-lock.json and a node_modules directory:

cd /path/to/your/project
npx @starcart.com/optional-deps-validate

If everything is correct, you’ll see:

✅  All optional dependencies declared by installed packages appear in package-lock.json.

Otherwise, it will list warnings for each missing optional dependency and exit with status code 1.

Example Warning

⚠️  [Warning] Package "@swc/core" declares optional dependency "@swc/core-darwin-arm64" but it is NOT listed in package-lock.json

One or more optional dependencies are missing from package-lock.json!

How it works

  1. Scans node_modules: Locates every installed package (including scoped packages) and reads its package.json.
  2. Collects Optional Deps: For each package’s optionalDependencies, the tool records each optional dep name.
  3. Parses package-lock.json: Gathers all package names listed in the lock file.
  4. Compares: Any optional dep name that doesn’t appear in the lock file is flagged as missing.

When to Use

  • Prevent Partial Lockfiles: Whenever you suspect npm install might have generated an incomplete package-lock.json (for instance, if you re-installed without removing node_modules).
  • CI Enforcement: Add npx optional-deps-validate as part of your build or test pipeline to ensure the lockfile is fully consistent before merging changes.

License

MIT