Guide · CRAClock · EU Cyber Resilience Act
How to generate an SBOM from package.json
By the Ingenious AI team · Published 14 November 2026 · Reviewed 14 November 2026
Short answer: CRAClock reads both dependency blocks of package.json — dependencies and devDependencies — and emits a CycloneDX component for each, with scope recorded (devDependencies marked as development scope) and the package's npm identity preserved, including @scope/name forms. A version is recorded only when the specifier is an exact version; range specifiers like ^2.1.0 or ~1.4.2 produce a component honestly without a version. The fix for a precise inventory is at the source: resolve and pin exact versions, the way a lockfile does.
Generate your free SBOM + readiness pack → Compare two releases free · See pricing
What is a package.json SBOM?
A package.json SBOM is a CycloneDX inventory generated from a JavaScript project's dependency declarations. CRAClock's parser walks the dependencies and devDependencies objects, creating one component per entry with its npm name (scoped names kept intact in the purl, pkg:npm/<name>@<version>), a version only where the specifier is exact, and a scope distinguishing runtime from development dependencies. It describes the project's declared composition with the same honesty rules as the Python parsers: stated, not guessed.
Two blocks, two scopes
JavaScript's manifest makes a distinction Python's does not: dependencies the product runs with, and devDependencies used to build and test it. A serious inventory wants both, labelled — runtime components because they ship, development components because build-chain compromise is product compromise. CRAClock's parser therefore walks both blocks and carries the distinction into the SBOM as component scope, so a later reader (or scanner, or diff) can reason about each class appropriately.
That scope field earns its keep immediately. A vulnerability in a runtime component is a product exposure; in a devDependency it is a pipeline exposure — different urgency, different fix, same duty to know. An SBOM that merged the blocks would force every consumer to treat every alert as a product alert, manufacturing alert fatigue; the scoped SBOM keeps the signal graded, which is a theme the remediation-priority guide develops.
The range problem: ^ and ~
npm's specifier culture is range-based: ^2.1.0 means 'compatible with 2.1.0', ~1.4.2 a narrower band, and the actual installed version is decided at install time and recorded in the lockfile, not the manifest. CRAClock's parser therefore records a component's version only when the specifier is an exact version; a range yields the component without a version — the honest representation of what package.json alone knows.
Feel the consequence for vulnerability matching: a component without a version cannot be matched against OSV's version-specific records, so a package.json-derived SBOM from a typical range-heavy manifest has systematic blind spots. This is not a parser defect; it is the manifest telling the truth about its own precision. The remedies are to pin exact versions in the manifest where the project's workflow allows, or to treat the lockfile-resolved set as the inventory of record for the shipped product — the same 'generate from what actually installs' principle as the Python side.
Scoped packages and npm identity
npm names carry structure other ecosystems lack: the @scope/name form used by organisations and frameworks (@babel/core, @types/node). The parser preserves scoped names in the component name and purl, because ecosystem identity is exact — pkg:npm/@babel/[email protected] is a different component from any unscoped namesake, and vulnerability data keys on the full identity. Name mangling would break matches silently, which is worse than no match at all.
Version strings in npm can also carry build metadata and prerelease tags; an exact specifier is taken as written. The parser's threshold is exactness, not tidiness: if the specifier names precisely one version, the component claims it; anything that names a set of possible versions claims none. That single rule keeps the SBOM's every version an assertion the manifest actually made.
Reading your first package.json SBOM
Expect three numbers to tell the story: total components across both blocks, how many carry exact versions, and the runtime/development split. A typical first run on an actively developed app shows a large devDependency contingent (build tooling accumulates) and a minority of exact versions — a picture that usually surprises the team twice: once at how much tooling the build depends on, and once at how loosely the manifest pins any of it.
Neither surprise is a failure; both are the inventory doing its job of replacing assumption with fact. The work list writes itself: pin or lockfile-resolve the runtime set first (product exposure), then decide the build set's governance (pin in the manifest, or accept the lockfile as record and regenerate from it in the release process). The checklist's pinning item tracks the same numbers CRAClock's summary shows, so progress is visible in both places.
package.json in a multi-manifest product
Real products mix manifests: a JavaScript frontend with a Python API, each with its own SBOM, held as separate products or components of one in the CRAClock console. The discipline is uniform across ecosystems — generate from each real manifest, keep scopes and versions honest, refresh per release, diff to review change. The JavaScript side's peculiarities (ranges, scopes, dev blocks) are handled by its parser; the governance around it is identical to the Python side's, which is what makes a mixed-stack vendor's programme coherent rather than two half-programmes.
Your 5-action checklist
- Paste package.json into the free CRAClock job and note components total, versions exact, and the runtime/development split.
- For runtime dependencies with range specifiers, pin exact versions or adopt the lockfile-resolved set as the inventory of record.
- Keep devDependencies in the SBOM habit — scoped as development — rather than excluding the build chain from view.
- Check scoped packages (@scope/name) render with full identity in their purls.
- Regenerate at each release and diff, reviewing runtime changes first and development changes with pipeline eyes.
Work through the list in order. The free CRAClock job on the home page produces the SBOM, the dated checklist and the reporting runbook that several of these actions depend on.
Worked example: 112 components, 14 exact versions
A fictional SaaS frontend's package.json produced an SBOM of 112 components — 44 dependencies, 68 devDependencies — of which only 14 carried exact versions; the rest wore ^ and ~ ranges. The team's first reaction was that the SBOM was 'mostly empty'; the second, on reflection, was that the manifest itself was mostly approximate, and the SBOM had merely declined to hide it. Their scanner results had the same shape: exact matches for 14 components, silence for 98.
The team did not rewrite the manifest's culture overnight. They pinned the 44 runtime dependencies exactly (a lockfile-assisted afternoon), lifting exact versions to 58 of 112, and scheduled the build-toolchain pinning as a follow-up. The next scan spoke about the entire runtime surface for the first time — including one genuinely affected component that range-blindness had been concealing, which jumped the remediation queue on evidence rather than anxiety.
Keep going
- Free SBOM + readiness pack — paste a manifest, get the CycloneDX SBOM, checklist and runbook.
- SBOM change-to-impact analysis — diff two releases before you ship.
- CRAClock pricing — Free, Pro $29/month and Team $79/month.
- All CRAClock guides — the full library for small EU software vendors.
- CRAClock console — products, scans, incidents, vault and trust pages.
- What is an SBOM and why does the CRA require one?
- Should devDependencies be included in an SBOM?
- What is a package URL (purl) in an SBOM?
- Why pin dependencies to exact versions for CRA compliance?
- What are the limitations of a manifest-based SBOM?
- How to generate an SBOM from requirements.txt
- What is the risk of unpinned dependencies?
Frequently asked questions
Why does my SBOM component have no version when package.json clearly shows ^2.1.0?
Because ^2.1.0 names a range of acceptable versions, not the version installed. CRAClock records a version only for exact specifiers; claiming one from a range would be guessing, and a guessed version corrupts vulnerability matching. Pin exactly, or inventory from the resolved lockfile set.
Are devDependencies really part of an SBOM?
Yes — labelled with development scope. They are components your build depends on, and build-chain vulnerabilities are real exposures. Scope lets consumers grade them differently from runtime components without losing sight of them.
How are scoped npm packages (@babel/core) represented?
With their full identity: name and purl preserve the @scope/name form (pkg:npm/@babel/core@<version>), matching how npm and vulnerability data identify them.
Should I generate the SBOM from package.json or package-lock.json?
package.json gives the declared view CRAClock parses today, with its honesty about ranges. The governing principle is to inventory what actually installs: if your release process resolves through the lockfile, make the resolved set your inventory of record and pin the manifest to match it as closely as your workflow allows.
Does the parser read other package.json fields?
The SBOM is built from the dependency blocks — dependencies and devDependencies — because components are the SBOM's subject. Product naming for the runbook and checklist comes from the product record you create, keeping each artefact's source clean.
CRAClock prepares drafts and evidence; regulatory submission is always performed by you in ENISA's Single Reporting Platform. This guide is general information about the duties CRAClock supports, not legal advice.