SBOMs for JavaScript and Node.js
sbombox generate uses npm sbom or pnpm sbom when your lockfile is committed, leaves dev dependencies out, and falls back to a universal tool for Yarn and Bun. This page covers that path, the manual commands, and the errors you are likely to see.
At a glance
| Package manager | Built-in SBOM command | What sbombox generate runs | Lockfile to commit |
|---|---|---|---|
| npm 9.5+ | Yes, npm sbom | npm sbom (lockfile only, no dev dependencies), then cyclonedx-npm, then cdxgen or syft | package-lock.json or npm-shrinkwrap.json |
| pnpm 11.1+ | Yes, pnpm sbom | pnpm sbom --prod, then the same with --lockfile-only if the store is empty, then cdxgen or syft | pnpm-lock.yaml |
| Yarn 4 | No | cdxgen or syft | yarn.lock |
| Bun | No | cdxgen or syft | bun.lock (not yet read as a lockfile by SBOMBox) |
SBOMBox only uses a built-in command when its lockfile is in the project and the package manager is new enough. Otherwise it moves to the next tool. A tool that fails, or returns an SBOM with no components, also falls through to the next one.
Generate with SBOMBox
Install the CLI once, then run it from the directory that holds package.json and the lockfile. See Install for options.
curl -fsSL https://sbombox.com/install.sh | sh
sbombox generate -o sbom.json
sbombox score sbom.jsonThe CLI prints which tool ran, for example Detected: npm - generated with npm sbom. The output is CycloneDX 1.6 by default. Pass -f spdx for SPDX 2.3.
To upload in the same step, add --upload. To gate a commit or build on quality without uploading, use sbombox check:
sbombox generate --upload
# Generate, score and discard; exit 1 below 7/10
sbombox check --fail-under 7To pin the choice, set SBOMBOX_GENERATOR to one or more generator names, comma-separated. SBOMBox tries them in that order and skips any that are not installed. An unknown name fails with the list of valid names.
SBOMBOX_GENERATOR=cyclonedx-npm,syft sbombox generate -o sbom.jsonValid names for JavaScript: npm-sbom, pnpm-sbom, pnpm-sbom-lockfile, cyclonedx-npm (alias npm), cdxgen, syft.
Use the package manager's own tool
Every command below builds a release SBOM: dev dependencies are left out and the root component is typed as an application. Upload the result with sbombox push.
npm 9.5 or later. npm sbom writes to stdout only, so redirect it to a file.
npm sbom --sbom-format cyclonedx --sbom-type application --omit dev --package-lock-only > sbom.json--omit devis required. Withnode_modulesinstalled, npm marks dev dependenciesscope: "required", so tools such as test runners appear as shipped code.--package-lock-onlyreads the lockfile and works on a fresh checkout. Without it and withoutnode_modules, npm fails withESBOMPROBLEMS.--sbom-type applicationmatters: npm types the root aslibraryby default.- npm writes CycloneDX 1.5 or SPDX 2.3 (
--sbom-format spdx) and usesname@versionas bom-refs. npm sbomreads onlypackage-lock.jsonandnpm-shrinkwrap.json. It does not readyarn.lockorpnpm-lock.yaml.
Measured on 16 November 2026 with npm 12.2.0 on a small test project: npm sbom scored 8.4/10 (B) with node_modules installed and 8.1/10 with --package-lock-only. Both passed NTIA, CISA 2025, BSI TR-03183-2 2.1.0 and CRA readiness, except supplier, which was partial.
pnpm 11.1 or later. Always pass --out; without it pnpm prints NDJSON to stdout.
pnpm install --frozen-lockfile
pnpm sbom --sbom-format cyclonedx --sbom-spec-version 1.6 --sbom-type application --prod --out sbom.json- pnpm reads licenses from its store, so install first. On a fresh checkout with an empty store, add
--lockfile-only. That works but drops licenses. - pnpm leaves component hashes out. When SBOMBox runs pnpm for you, it copies the SHA-512 integrity values from
pnpm-lock.yamlonto the components. - Without
--prod, dev-only components are kept and markedscope: "excluded".
Measured on 16 November 2026 with pnpm 11.28.12: the store-backed SBOM scored 6.0/10 as written by pnpm (licenses, no hashes) and 7.9/10 after SBOMBox added the hashes. --lockfile-only scored 4.7/10 (no hashes, no licenses). For pnpm, prefer sbombox generate over running pnpm sbom yourself.
Yarn 4. Yarn has no SBOM command. The CycloneDX Yarn plugin needs Yarn 4 and Node.js 20.18 or later.
yarn add --dev @cyclonedx/yarn-plugin-cyclonedx
yarn exec cyclonedx-yarn --production --output-format JSON --output-file sbom.jsonPass --production explicitly. The plugin only excludes dev dependencies by default when NODE_ENV is production.
Bun. Bun has no SBOM command. sbombox generate falls back to cdxgen or syft. Check the component count and the score before you rely on the result.
Then, for a file made by any of these tools:
# See what lowers the score
sbombox score sbom.json --format detailed
# Check a ruleset, e.g. EU Cyber Resilience Act readiness
sbombox compliance sbom.json -p cra-readiness
# Upload it to the active project, labelled with the release
sbombox push sbom.json --version v1.4.0Monorepos and workspaces
- npm and pnpm workspaces share one lockfile at the repository root. Run
sbombox generatefrom the root to get one SBOM for the whole repository. - Running it in a workspace package directory finds no lockfile there, so SBOMBox warns that versions may be guessed. Generate at the root instead.
- For one SBOM per deployable package with pnpm,
pnpm sbom --splitwrites one SBOM per workspace package. Upload each to its own SBOMBox project withsbombox push FILE --project ID. - A repository that also contains Python, Go or another ecosystem is scanned with a universal tool first (cdxgen if installed, else syft). See Unify SBOMs for combining per-language SBOMs.
Known gaps and how SBOMBox handles them
| Gap | Effect | What SBOMBox does |
|---|---|---|
npm sbom includes dev dependencies by default | Test and build tools listed as shipped code | Always passes --omit dev |
npm sbom types the root as a library | Wrong root component type | Passes --sbom-type application |
npm sbom emits CycloneDX 1.5 only | Older spec version | Re-writes the result as CycloneDX 1.6 (or SPDX 2.3 with -f spdx) |
pnpm sbom has no hashes | Lower integrity score | Fills SHA-512 hashes from pnpm-lock.yaml |
pnpm sbom fails with an empty store | No SBOM on a fresh CI checkout | Retries with --lockfile-only |
| No supplier data in npm metadata | Supplier check partial | Reports it; see Rulesets for how each ruleset scores it |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
npm sbom found packages missing from, or invalid in, package-lock.json. Run npm install, commit package-lock.json, and try again. | package-lock.json is out of sync with package.json | Run npm install, commit package-lock.json, run again |
ESBOMPROBLEMS when you run npm sbom yourself | No node_modules and no --package-lock-only | Add --package-lock-only, or run npm ci first |
No lockfile for npm: transitive dependencies may be missing and versions may be guessed. | No lockfile committed | Commit package-lock.json, pnpm-lock.yaml or yarn.lock |
Generated with syft, not npm sbom | npm older than 9.5, or no package-lock.json | Upgrade npm, or commit the lockfile |
| Test runners and linters in the SBOM | Built without --omit dev or --prod | Use the commands on this page, or sbombox generate |
| pnpm SBOM has no licenses | Built with --lockfile-only or an empty store | Run pnpm install --frozen-lockfile first |
SBOMBOX_GENERATOR names unknown generator(s) ... | Typo in a generator name | Use a name from the list in the error |
In CI, run the same commands. See GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, Bitbucket Pipelines or CircleCI, or use the GitHub Action.
Frequently asked questions
Do I need cyclonedx-npm?
Not with npm 9.5 or later or pnpm 11.1 or later. The installer adds cyclonedx-npm only when Node.js 20+ is present with npm older than 9.5.
Should I commit node_modules for a better SBOM?
No. Commit the lockfile. SBOMBox reads it directly, so a fresh CI checkout works without installing anything.
Which tool gives the best score?
In our 16 November 2026 test, npm sbom scored highest (8.4/10). For pnpm, sbombox generate scored 7.9/10 because it adds hashes pnpm leaves out.