Skip to content

feat(pm): handle npm 12 blocked install scripts in create and approve-builds - #2336

Draft
fengmk2 wants to merge 1 commit into
mainfrom
feat/npm-v12-compat
Draft

feat(pm): handle npm 12 blocked install scripts in create and approve-builds#2336
fengmk2 wants to merge 1 commit into
mainfrom
feat/npm-v12-compat

Conversation

@fengmk2

@fengmk2 fengmk2 commented Aug 5, 2026

Copy link
Copy Markdown
Member

npm 12 (now latest) skips dependency install scripts that the allowScripts field in package.json does not cover; the install succeeds with a warning. Approval only records the allowlist: a reinstall short-circuits on the up-to-date tree, and only npm rebuild executes previously skipped scripts. npm 12 also stops resolving git and remote tarball dependencies by default (EALLOWGIT / EALLOWREMOTE).

vp treated npm as "runs scripts by default", so vp create with npm 12 left native direct dependencies silently unbuilt. This PR:

  • parses the npm 12 blocked-scripts install warning (parseNpmBlockedScripts) and surfaces gated direct dependencies in vp create like pnpm/bun/yarn; approval runs vp pm approve-builds <pkg> then vp pm rebuild <pkg>, and retry hints point at rebuild instead of reinstall
  • version-gates the vp pm approve-builds npm note: npm >= 12 explains the approve-then-rebuild two-step, npm 11.16 - 11.x keeps the advisory wording (allowlist recorded, scripts still run), denials get no note
  • adds the command_pm_approve_builds_npm12 PTY fixture recorded against real npm 12.0.2 and re-records the npm11 fixture for the reworded note
  • updates the create and install guides: npm joins the gated-scripts package managers, new "Dependency build scripts (npm v12+)" section, and a note on the allow-git / allow-remote defaults

The npm 11.x wording ("not yet covered") is deliberately not parsed: those versions still run scripts, so there is nothing to fix up.

Verified end-to-end against npm 12.0.2: install of a project with a gated direct dep detects it, auto-approval writes allowScripts and the rebuild runs its postinstall. 54 TS unit tests and 34 Rust tests pass; all three npm approve-builds snapshot fixtures pass.

Audited but left as follow-ups: vp install -g has no --allow-scripts plumbing (vp's own global installs have no scripts), vp migrate preserves git/remote specs that now fail under npm 12, and migrate installs do not surface gated builds (pre-existing, also true for pnpm).

Closes #1823

…-builds

npm 12 skips dependency install scripts that the allowScripts field in
package.json does not cover, and stops running scripts on approval: only
npm rebuild executes previously skipped scripts.

- Parse the npm 12 blocked-scripts install warning and surface gated
  direct dependencies in vp create like pnpm/bun/yarn, approving via
  vp pm approve-builds followed by vp pm rebuild
- Version-gate the vp pm approve-builds npm note: npm >= 12 points at
  vp pm rebuild, npm 11.16 - 11.x keeps the advisory wording
- Add the command_pm_approve_builds_npm12 PTY fixture (npm@12.0.2) and
  re-record the npm11 fixture for the reworded note
- Document the npm 12 allowScripts flow and the allow-git/allow-remote
  resolution defaults in the create and install guides

Closes #1823
@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview ready!

Name Link
🔨 Latest commit 25a2c53
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a730000ad4bf90008c05d0c
😎 Deploy Preview https://deploy-preview-2336--viteplus-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

✅ Staging deployment successful!

Preview: https://viteplus-staging.void.app/
Commit: 25a2c53

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Native binary sizes (25a2c53)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.

Artifact Format Base PR Change
vp (Linux x64) Binary 10.52 MiB 10.52 MiB 0 B (0.00%)
vp (Linux x64) gzip -9 4.55 MiB 4.55 MiB +214 B (+0.00%)
NAPI (Linux x64) Binary 33.66 MiB 33.66 MiB 0 B (0.00%)
NAPI (Linux x64) gzip -9 13.04 MiB 13.05 MiB +586 B (+0.00%)
vp (macOS ARM64) Binary 7.84 MiB 7.84 MiB 0 B (0.00%)
vp (macOS ARM64) gzip -9 3.96 MiB 3.96 MiB +60 B (+0.00%)
NAPI (macOS ARM64) Binary 40.95 MiB 40.95 MiB 0 B (0.00%)
NAPI (macOS ARM64) gzip -9 17.26 MiB 17.26 MiB +216 B (+0.00%)
vp (Windows x64) Binary 8.43 MiB 8.43 MiB 0 B (0.00%)
vp (Windows x64) gzip -9 3.67 MiB 3.67 MiB +319 B (+0.01%)
NAPI (Windows x64) Binary 27.81 MiB 27.81 MiB +512 B (+0.00%)
NAPI (Windows x64) gzip -9 10.88 MiB 10.88 MiB +343 B (+0.00%)
Trampoline (Windows x64) Binary 203.00 KiB 203.00 KiB 0 B (0.00%)
Trampoline (Windows x64) gzip -9 97.91 KiB 97.91 KiB -3 B (-0.00%)
Installer (Windows x64) Binary 4.46 MiB 4.46 MiB 0 B (0.00%)
Installer (Windows x64) gzip -9 2.09 MiB 2.09 MiB -1 B (-0.00%)

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.

Track npm v12 compatibility

1 participant