Skip to content

fix: report blocked install scripts when reify or a root script fails - #9945

Open
lazerg wants to merge 2 commits into
npm:latestfrom
lazerg:fix/9943-skipped-scripts-warning
Open

fix: report blocked install scripts when reify or a root script fails#9945
lazerg wants to merge 2 commits into
npm:latestfrom
lazerg:fix/9943-skipped-scripts-warning

Conversation

@lazerg

@lazerg lazerg commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What / Why

reifyFinish is what prints the "install scripts blocked because they are not covered by allowScripts" warning, and it runs last. Anything that throws before it, either the reify itself or one of the root lifecycle scripts that follow it, exits the command with the warning never printed. That is the case where it matters most: the root prepare typically fails because a dependency's postinstall was skipped, and all the user gets is an unrelated stack trace from somewhere inside node_modules. npm install <pkg> prints the warning fine, since that path never runs the root lifecycle scripts at all.

npm install and npm ci now report the blocked scripts before rethrowing. A failed reify rolls its tree back, so the report reads off the ideal tree rather than actualTree. The message itself moved into its own module so the commands and reify-output can share it; its content is unchanged.

Testing

New regression tests on both commands for a root prepare that exits non-zero, plus one for a reify that fails outright, each with a dependency whose postinstall is blocked, asserting the warning is logged before the command rejects. Also checked by hand against a project with file: dependencies, covering both a failing root prepare and a failing dependency script: the warning lands on stderr, prints once on the success path, --silent still suppresses it, and --json leaves stdout valid JSON.

References

Fixes #9943

@lazerg
lazerg requested review from a team as code owners September 3, 2026 08:50
@lazerg lazerg changed the title fix: report blocked install scripts when a root lifecycle script fails fix: report blocked install scripts when a failed reify or root script exits early Sep 3, 2026
@lazerg lazerg changed the title fix: report blocked install scripts when a failed reify or root script exits early fix: report blocked install scripts when reify or a root script fails Sep 3, 2026
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.

[BUG] npm install doesn't report post-install script warning when root project has prepare hook that fails

1 participant