Skip to content

fix: avoid conflicting prefer config flags#503

Open
pupuking723 wants to merge 1 commit into
npm:mainfrom
pupuking723:fix/prefer-online-offline-config
Open

fix: avoid conflicting prefer config flags#503
pupuking723 wants to merge 1 commit into
npm:mainfrom
pupuking723:fix/prefer-online-offline-config

Conversation

@pupuking723

Copy link
Copy Markdown

Fixes #472.

FetcherBase currently always forwards both --prefer-offline=false and --prefer-online=false to the inner npm install command used while preparing git dependencies. Newer npm treats these configs as mutually exclusive, so setting both keys, even to false, can trip the stricter validation.

This changes the generated npm CLI config so the prefer flags are only forwarded when they are enabled:

  • preferOffline: true adds --prefer-offline=true
  • preferOnline: true adds --prefer-online=true
  • the default path omits both prefer flags

The existing snapshot for the default config was updated, and the fetcher test now asserts the enabled/disabled cases explicitly.

Verification:

  • npx tap test/fetcher.js
    • Relevant assertions passed.
    • The command still exits non-zero when run as a single file because the repo's global coverage threshold expects the full suite.
  • npm run eslint -- lib/fetcher.js test/fetcher.js
  • git diff --check

I also ran npm test; it progressed through the relevant test/fetcher.js suite successfully, then stopped later in test/git.js during local fixture setup with ENOENT for test/tap-testdir-git/submodule-repo/package.json, which appears unrelated to this change.

@pupuking723 pupuking723 requested a review from a team as a code owner June 13, 2026 05:46
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] I think the npm pacote should also treat prefer-offline and prefer-online as mutually exclusive.

1 participant