How a Node.js repository is built, installed and released with pnpm, frontend or backend. Use when creating or configuring a Node project, adding a package.json, choosing a package manager, installing or updating dependencies (pnpm itself included), scaffolding frontend apps or JS/TS tooling, setting up CI for a Node repository, or publishing a package. It mandates pnpm 12 with supply-chain hardening: no dependency build script runs unless the person allows it (allowBuilds), a 3-day minimum r...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Build Node?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/jorgecostamacia-build-node)
---
name: build-node
description: >-
How a Node.js repository is built, installed and released with pnpm,
frontend or backend. Use when creating or configuring a Node project,
adding a package.json, choosing a package manager, installing or updating
dependencies (pnpm itself included), scaffolding frontend apps or JS/TS
tooling, setting up CI for a Node repository, or publishing a package. It
mandates pnpm 12 with supply-chain hardening: no dependency build script
runs unless the person allows it (allowBuilds), a 3-day minimum release
age enforced strictly, the dependency audit failing from low, no exotic
transitive sources, pinned package manager and Node 26, frozen lockfile in
CI, no one-off dlx or npx downloads, the private registry's token only in
the environment (.npmrc), SemVer, packages published only by the release
pipeline, and no change to a CI workflow, the .claude settings or a gate
without asking the person.
---
# Building Node repositories
The conventions every Node repository follows, front or back: its dependencies through **pnpm 12**, its Node version, its scripts, the release age of what it installs, and publishing only from CI. Code style and its gates are `code-style-node`'s; tests are `testing-node`'s.
Why pnpm and this configuration: npm supply-chain attacks run through the install scripts of freshly published versions. This setup cuts both vectors.
## Rules
1. **pnpm, not npm/yarn** — strict `node_modules` (no phantom dependencies), and no dependency build script runs unless the person allows it.
2. **No dependency build script runs by default.** Install scripts are the main path of a supply-chain attack: a hijacked package runs its code when someone installs it, before anyone uses it. That is the same risk that the release-age wait covers. `allowBuilds` is a map of package → `true` (may run its scripts) / `false` (denied). With `strictDepBuilds: true` (the default), an install that meets a package with build scripts and no entry **fails**, so no build stays undecided. Each entry is the person's decision, and the person writes it by hand. An agent never adds `true`: it explains what the script does and why the package would need it. Most packages do not need their script (see the `esbuild` example below). Your own `package.json` scripts are not affected. (pnpm v11 replaced the older build settings with `allowBuilds`.)
3. **`minimumReleaseAge: 4320`** (3 days, in minutes): never install a version published less than 3 days ago. People usually detect and pull trojanized releases within that window. pnpm's own default since v11 is 1440 (1 day). Set it explicitly: that also turns on `minimumReleaseAgeStrict`. Then, if no version in range is old enough, resolution fails instead of silently taking a newer one. An exception goes in `minimumReleaseAgeExclude`, as a package name or a scope pattern (`@org/*`). Every exception is the person's decision: the packages that you or your organization publish, the fix for a known vulnerability, or any other case. An agent can propose one, with its reason. It never adds one alone, and never updates silently.
4. **No exotic transitive sources**: keep `blockExoticSubdeps: true` (the default) — only the root `package.json` may point at a git repository or a tarball URL.
5. **Pin the package manager**: put `"packageManager": "pnpm@<exact version>"` in package.json, so every developer and CI run the same pnpm. Add `"engines": { "pnpm": ">=12" }` as the floor. pnpm refuses to work in a project whose `engines.pnpm` it does not satisfy, so an older pnpm stops with a clear error and does not misread v12 settings. A change of the pin is a dependency update like any other: pick a release at least 3 days old. `pnpm self-update` does **not** apply the repository's `minimumReleaseAge`.
6. **Pin Node too — 26.** With `devEngines.runtime`, pnpm resolves the version, records it exactly (with its checksum) in the lockfile and downloads it when it is missing. Scripts use that runtime. Since v12, a `node` installed through pnpm (`pnpm add -g node`) uses it too when it runs inside the project. A Node from another installer that comes first on the `PATH` does not switch, so run the project's tools through its `package.json` scripts. `engines.node` states the same floor for anyone consuming the package, and CI sets up the same major (`actions/setup-node` with `node-version: 26.x`).
7. **Lockfile committed; every install follows it.** CI installs with `--frozen-lockfile` (the default on CI), and so does an agent on a developer's machine: `pnpm install --frozen-lockfile`. When the lockfile does not match `package.json`, stop and tell the person; never regenerate the lockfile to make the install pass. pnpm 12 dropped `--frozen-lockfile false`: write `--no-frozen-lockfile`.
8. **Never write a version from memory.** Add or bump a dependency only when the person asks. Take the exact version from the registry (`pnpm view <package> version time`), check its age against rule 3, and pin it. A version that an agent remembers can be wrong, or newer than the wait allows.
9. **Transitive pins via `overrides`** when a vulnerable transitive needs forcing above a bad version.
10. **The dependency audit fails from `low`**: `audit.level: low` in `pnpm-workspace.yaml`, and CI runs `pnpm audit`, so every advisory fails the run, as the NuGet audit does on .NET. The fix is an update, or an `overrides` pin of the transitive package. To let pnpm apply the fix, run `pnpm audit --fix --no-add-release-age-exclusions`: since pnpm 12.23, a plain `--fix` also adds the fixed version to `minimumReleaseAgeExclude`, which is an exception that only the person decides. For the same reason, never pass `--minimum-release-age` or `--minimum-release-age-exclude` to `pnpm install`: they change the wait for one run. If an advisory does not apply, propose to exclude it by its GHSA id (`audit.ignore` in `pnpm-workspace.yaml`, which takes GHSA ids only), with your analysis. The person decides: an agent never excludes an advisory alone.
11. **Settings live in `pnpm-workspace.yaml`**, where pnpm 12 checks them. An unknown key gives a warning with the closest real name. When the pinned pnpm runs, it fails with `ERR_PNPM_UNRECOGNIZED_WORKSPACE_SETTINGS`, so a typo in a security setting does not pass in silence.
12. **No one-off downloads**: `pnpm dlx`, `pnpx` and `npx` fetch a package outside the lockfile, so `minimumReleaseAge`, the `allowBuilds` review and the frozen lockfile do not apply to it. A tool the project uses (a linter, a renderer, a generator) is a devDependency, run with `pnpm exec <tool>` or a `package.json` script. The only exception is a one-off migration that the person asks for, with the version pinned exactly. The person runs it: give them the command (`pnpm dlx <tool>@<exact version> …`). An agent guard can block one-off downloads, and should.
13. **A private registry's credentials never enter the repository.** The `.npmrc` at the root maps the scope to the registry (`@org:registry=https://<registry host>/`) and reads the token from the environment (`//<registry host>/:_authToken=${NPM_TOKEN}`). A developer sets the variable on the machine, and CI takes it from a secret. Never commit a token, in `.npmrc` or in any other file.
14. **Versions follow SemVer, and only `version` in `package.json` holds one.** The version grows as Conventional Commits says: a breaking change is a major, a `feat` a minor, and a `fix`, `perf` or `revert` a patch. The other types (tests, docs, CI, build, refactors) change nothing for consumers, so release-please hides them: they make no release. A dependency update that reaches consumers is a `fix(deps)`. release-please opens or updates the release pull request, and bumps `version` in it (release type `node`). It stays open until the person wants a release. A package repository also gets a prerelease: CI publishes the next patch of `version`, `X.Y.(Z+1)-dev.<run>`, on each merge to `main` under the npm dist-tag `dev`, so `latest` stays the stable version. Never publish a version twice.
15. **Only the release pipeline publishes.** A package reaches the registry only through the repository's release pipeline in CI, like a NuGet package. Never run `pnpm publish` or `npm publish`. If the person asks for a publish, point them to the release pipeline.
16. **Ask before you touch a gate.** Ask the person before you edit a CI workflow, the `.claude` settings or any gate (the audit, the release-age wait, `allowBuilds`, the frozen lockfile, a format, lint or type check). Never weaken a gate on your own: fix what makes it fail.
## Config
`pnpm-workspace.yaml`:
```yaml
minimumReleaseAge: 4320 # 3 days, in minutes; explicit, so minimumReleaseAgeStrict is on
allowBuilds: # the person's decisions: true runs the build scripts, false denies them
esbuild: false # its binary comes in its per-platform packages, so the build is not needed
audit:
level: low # every advisory fails the audit (rule 10)
```
`package.json`:
```json
{
"packageManager": "pnpm@<exact version>",
"engines": {
"node": ">=26",
"pnpm": ">=12"
},
"devEngines": {
"runtime": {
"name": "node",
"version": "^26",
"onFail": "download"
}
}
}
```
Take `<exact version>` from the registry (`pnpm view pnpm version time`), at least 3 days old (rules 5 and 8). Never write it from memory.
Optional, stricter: `trustPolicy: no-downgrade` fails an install when a package's trust evidence (provenance, trusted publishing) drops below what its earlier releases had. That drop is the signature of a hijacked maintainer account. Exceptions go in `trustPolicyExclude` (`'pkg@1.2.3'`); ask the person before you add one.
## When scaffolding or updating
- New Node project → this setup from the first commit, before any `pnpm add`.
- An install that stops on a build script with no entry: stop, and tell the person what the script does and whether the package needs it. The person writes the entry. An agent never adds `true`, and never sets `dangerouslyAllowAllBuilds`.
- Never work around a blocked script with `pnpm rebuild` or a manual run of the script.
- `pnpm outdated` lists what can move; an update still lands only versions older than `minimumReleaseAge`.