Skip to content

Avoid npm warnings by supporting MODULE_BINARY_HOST_MIRROR env variable#953

Open
yunnysunny wants to merge 2 commits intomapbox:masterfrom
yunnysunny:master
Open

Avoid npm warnings by supporting MODULE_BINARY_HOST_MIRROR env variable#953
yunnysunny wants to merge 2 commits intomapbox:masterfrom
yunnysunny:master

Conversation

@yunnysunny
Copy link
Copy Markdown

@yunnysunny yunnysunny commented Apr 7, 2026

Description

With newer versions of npm (v10+), using environment variables in the form of:

npm_config_<module>_binary_host_mirror

will trigger warnings such as:

npm warn Unknown env config "<module>-binary-host-mirror"

This happens because npm now validates environment variables prefixed with npm_config_* against its known configuration keys, and custom keys used by tools like node-pre-gyp are no longer recognized.

Changes

To address this issue, this PR introduces support for an alternative environment variable:

<MODULE>_BINARY_HOST_MIRROR

Specifically:

The code now checks for npm_config_<module>_binary_host_mirror
Falls back to process.env.<MODULE>_BINARY_HOST_MIRROR

@yunnysunny yunnysunny requested a review from a team as a code owner April 7, 2026 09:42
@yunnysunny
Copy link
Copy Markdown
Author

It's been some time since this PR was proposed. Could we consider this pull request now? @cclauss

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to avoid npm v10+ warnings for custom npm_config_* env vars by adding support for a non-npm_config_ environment variable fallback when selecting a binary download host mirror.

Changes:

  • Add an uppercase (non-npm_config_) environment variable fallback for the binary host mirror in versioning.evaluate().
  • Add a unit test covering host resolution via the uppercase environment variable.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/util/versioning.js Adds fallback lookup for a non-npm_config_ env var when computing opts.host.
test/versioning.test.js Adds a test validating host mirror detection via an uppercase env var.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/versioning.test.js
Comment thread lib/util/versioning.js Outdated
Comment thread lib/util/versioning.js
@yunnysunny yunnysunny changed the title Avoid npm warnings by supporting MODULE_BINARY_MIRROR env variable Avoid npm warnings by supporting MODULE_BINARY_HOST_MIRROR env variable Apr 21, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

2 participants