Skip to content

fix(arborist): use omit when checking ideal tree engine, centralize shouldOmit logic #8372

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 1 commit into
base: latest
Choose a base branch
from

Conversation

owlstronaut
Copy link
Contributor

@owlstronaut owlstronaut commented Jun 20, 2025

fixes #8369
fixes #6805

Fix: Skip engine validation for omitted dependencies

Problem

When running npm install --omit=dev, npm incorrectly validates engine requirements for devDependencies that won't be installed, causing unnecessary install failures. For example, a project with devDependencies requiring Node >=20.6.0 would fail to install on Node 18.x even when using --omit=dev.

Solution

Modified Arborist's engine validation to skip checking omitted dependencies. Added a centralized shouldOmit() method to the Node class and updated #checkEngineAndPlatform() to respect omit flags. Now npm install --omit=dev succeeds when devDependencies have incompatible engine requirements, while still validating engines for dependencies that will actually be installed.

Changes

  • lib/node.js: Added shouldOmit() method for consistent omit logic
  • lib/arborist/build-ideal-tree.js: Skip engine checks for omitted dependencies
  • lib/arborist/reify.js, lib/audit-report.js: Use centralized omit logic
  • Added comprehensive tests and fixtures for all omit scenarios

@owlstronaut owlstronaut marked this pull request as ready for review June 20, 2025 18:45
@owlstronaut owlstronaut requested a review from a team as a code owner June 20, 2025 18:45
@owlstronaut owlstronaut changed the title fix(arborist): use omit when building ideal tree, centralize shouldOmit logic fix(arborist): use omit when checking ideal tree engine, centralize shouldOmit logic Jun 20, 2025
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] devDependencies considered for minimum version despite --omit-dev [BUG] Option engine-strict=true is not compatible with --omit=dev
1 participant