Languages

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

JavaScript package managers and how SBOMBox handles them
Package managerBuilt-in SBOM commandWhat sbombox generate runsLockfile to commit
npm 9.5+Yes, npm sbomnpm sbom (lockfile only, no dev dependencies), then cyclonedx-npm, then cdxgen or syftpackage-lock.json or npm-shrinkwrap.json
pnpm 11.1+Yes, pnpm sbompnpm sbom --prod, then the same with --lockfile-only if the store is empty, then cdxgen or syftpnpm-lock.yaml
Yarn 4Nocdxgen or syftyarn.lock
BunNocdxgen or syftbun.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.json

The 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 7

To 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.json

Valid 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

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

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.json

Pass --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.0

Monorepos and workspaces

Known gaps and how SBOMBox handles them

Gaps in JavaScript SBOM tooling
GapEffectWhat SBOMBox does
npm sbom includes dev dependencies by defaultTest and build tools listed as shipped codeAlways passes --omit dev
npm sbom types the root as a libraryWrong root component typePasses --sbom-type application
npm sbom emits CycloneDX 1.5 onlyOlder spec versionRe-writes the result as CycloneDX 1.6 (or SPDX 2.3 with -f spdx)
pnpm sbom has no hashesLower integrity scoreFills SHA-512 hashes from pnpm-lock.yaml
pnpm sbom fails with an empty storeNo SBOM on a fresh CI checkoutRetries with --lockfile-only
No supplier data in npm metadataSupplier check partialReports it; see Rulesets for how each ruleset scores it

Troubleshooting

Common JavaScript errors
SymptomCauseFix
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.jsonRun npm install, commit package-lock.json, run again
ESBOMPROBLEMS when you run npm sbom yourselfNo node_modules and no --package-lock-onlyAdd --package-lock-only, or run npm ci first
No lockfile for npm: transitive dependencies may be missing and versions may be guessed.No lockfile committedCommit package-lock.json, pnpm-lock.yaml or yarn.lock
Generated with syft, not npm sbomnpm older than 9.5, or no package-lock.jsonUpgrade npm, or commit the lockfile
Test runners and linters in the SBOMBuilt without --omit dev or --prodUse the commands on this page, or sbombox generate
pnpm SBOM has no licensesBuilt with --lockfile-only or an empty storeRun pnpm install --frozen-lockfile first
SBOMBOX_GENERATOR names unknown generator(s) ...Typo in a generator nameUse 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.