Skip to content

Introduce --fail-fast flag for npm run in workspaces #8323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: latest
Choose a base branch
from

Conversation

bralax
Copy link

@bralax bralax commented May 25, 2025

Right now, when using npm run --workspaces {cmd} or npm run -w {package1} -w {package2} {cmd}, npm will always run the command in every single package even if some packages fail.

This means that if packages depend on each other and the first package fails, the second package will still try to be built and also crash. This both wastes resources as we are running commands that we know will fail and also has the potential to corrupt or generate corrupt output as the conditions to execute the command are not met.

To handle this, this pull request introduces a new command line flag for use with npm run when working with workspaces named --fail-fast that when provided, rather than running the specified command in every package no matter success, once the first package fails, the command will stop running.

This flag was originally proposed in this RFC. The conversation in the RFC got blocked due to discussion about how this would benefit from also implementing topological sort for workspace packages which requires a lot more thought and careful handling. This flag is useful even without topological sort and can be implemented in a backwards compatible way with immediate impact to users so I decided to submit it as a community contribution.

References

Related to: npm/rfcs#575

@bralax bralax requested a review from a team as a code owner May 25, 2025 15:35
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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy