Skip to content

[BUG] Silent conflict when both prefer-offline=true and prefer-online=true are set, causing npm view to return stale cached data #9113

@gmvp3

Description

@gmvp3

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When both prefer-offline=true and prefer-online=true are set in the .npmrc configuration, npm silently prioritizes prefer-offline. Commands that query the registry, such as npm view version, skip the network request entirely and return stale cached data. The CLI provides no warning or error message indicating that these mutually exclusive flags are conflicting or that prefer-online is being ignored.

Expected Behavior

npm should detect when mutually exclusive flags like prefer-offline and prefer-online are active simultaneously. It should either output a clear warning message to the console (e.g., WARN config: mutually exclusive flags prefer-offline and prefer-online detected) so the user is aware of the conflict, or ensure that explicitly setting prefer-online overrides the offline preference to force a network validation.

Steps To Reproduce

No response

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions