Skip to content

build(npm): allowlist + enforce dependency install scripts - #1869

Merged
LeoMcA merged 4 commits into
mainfrom
fred-1868-npm-v12-forward-compat
Sep 10, 2026
Merged

build(npm): allowlist + enforce dependency install scripts#1869
LeoMcA merged 4 commits into
mainfrom
fred-1868-npm-v12-forward-compat

Conversation

@caugner

@caugner caugner commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

Add an allowScripts allowlist for the dependencies with install scripts, enable strict-allow-scripts, and bump the Node.js and npm pins.

Motivation

npm 12 no longer runs dependency preinstall/install/postinstall scripts unless the root package.json allowlists them, and npm ci still exits 0, so the failure only shows up later as a missing binary. Without the allowlist, packages such as @mdn/rari never fetch their binaries and lefthook never registers its git hooks.

Additional details

  • Entries are name-only (--no-allow-scripts-pin), so Dependabot bumps do not need re-approval commits, at the cost of trusting future versions of the listed packages.
  • strict-allow-scripts=true in .npmrc turns an uncovered install script into a hard npm ci error (honored by npm 11.16+, not only npm 12).
  • .nvmrc bumped to v24.20.0 and packageManager to npm 11.19.0; the previous pins (Node 24.15.0, npm 11.12.1) predate allowScripts support.
  • fsevents is denied (false): its tarball ships a prebuilt binary and has no install script, only the registry manifest lists one.
  • unrs-resolver stays allowed: its postinstall is a fallback that only does work when the platform-specific optional binding failed to install.
  • The allowlist does not propagate to consumers; mdn/content, mdn/mcp and mdn/dex add their own @mdn/rari entries in sibling PRs.
  • Verified: npm ci --strict-allow-scripts passes on npm 12.0.2 and 11.19.0; npm approve-scripts --allow-scripts-pending reports nothing.

Related issues and pull requests

Part of #1868.

npm 12 no longer runs `preinstall`/`install`/`postinstall` from
dependencies unless the root `package.json` lists them in `allowScripts`.
`npm ci` still succeeds, so a missing entry only surfaces later as a
missing binary.

Generated with `npm approve-scripts --all --no-allow-scripts-pin`, so the
entries are name-only and keep matching after a dependency bump.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

c4e1734 was deployed to: https://fred-pr1869.review.mdn.allizom.net/

Turns an uncovered dependency install script into a hard `npm ci` error
instead of a silently skipped script. npm 11.16+ already honors this
option, so it takes effect on the current toolchain, not only on npm 12.
Node 24.20.0 bundles npm 11.19.0, the first bundled version that
understands `allowScripts` and `strict-allow-scripts`, so CI runs
with an npm that actually enforces the install-script allowlist.
@caugner caugner changed the title build(npm): allowlist dependency install scripts build(npm): allowlist and enforce dependency install scripts Sep 8, 2026
@caugner caugner changed the title build(npm): allowlist and enforce dependency install scripts build(npm): allowlist + enforce dependency install scripts Sep 8, 2026
@caugner
caugner marked this pull request as ready for review September 8, 2026 16:33
@caugner
caugner requested review from a team and mdn-bot as code owners September 8, 2026 16:33
@caugner
caugner requested a review from LeoMcA September 8, 2026 16:33
Comment thread package.json
The published fsevents 2.3.3 tarball ships a prebuilt `fsevents.node`
and has no `install` script; only the registry manifest lists one, so
approving it grants nothing useful.
@LeoMcA
LeoMcA merged commit 56cdf09 into main Sep 10, 2026
13 checks passed
@LeoMcA
LeoMcA deleted the fred-1868-npm-v12-forward-compat branch September 10, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants