Skip to content

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

Open
caugner wants to merge 3 commits into
mainfrom
fred-1868-npm-v12-forward-compat
Open

build(npm): allowlist + enforce dependency install scripts#45569
caugner wants to merge 3 commits into
mainfrom
fred-1868-npm-v12-forward-compat

Conversation

@caugner

@caugner caugner commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

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, @mdn/rari, gifsicle, mozjpeg and pngquant-bin 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.14.0, npm 11.9.0) predate allowScripts support.
  • npx @mdn/rari and npx @mdn/fred in pr-test.yml resolve from this repo's node_modules, so the allowlist covers them.
  • 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 mdn/fred#1868.

Fixes mdn/fred#1867.

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 added system [PR only] Infrastructure and configuration for the project size/s [PR only] 6-50 LoC changed labels Sep 8, 2026
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.js 24.20.0 bundles npm 11.19.0, the first bundled npm version
that understands `allowScripts` and `strict-allow-scripts`, so CI and
local installs run with an npm that 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 review from LeoMcA and removed request for a team September 8, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s [PR only] 6-50 LoC changed system [PR only] Infrastructure and configuration for the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The 'npm run start' command exits with file not found error

2 participants