Skip to content

[FEATURE]: v2 install script: respect a custom npm registry (NPM_CONFIG_REGISTRY) #66814

Duplicate

Description

@fellinga

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

The v2 install script (https://opencode.ai/v2/install) downloads the CLI from the npm registry, but the registry URL is hardcoded to https://registry.npmjs.org in three places:

  • the version check for @opencode/cli-<target>
  • the fallback check for @opencode-ai/cli-<target>
  • the tarball download ($registry/$package_name/-/cli-<target>-<version>.tgz)

In corporate and CI environments, outbound traffic is often only allowed to an internal npm mirror (Artifactory, Nexus, Verdaccio, …). Those environments already set NPM_CONFIG_REGISTRY, but the installer ignores it, so installing v2 fails even though the mirror serves the exact same packages.

Current workaround (it works, but it's brittle):

curl -fsSL https://opencode.ai/v2/install \
  | sed "s#https://registry.npmjs.org#${NPM_CONFIG_REGISTRY%/}#g" \
  | bash -s -- --version "$OPENCODE_VERSION" --no-modify-path

Proposal: read the registry from an environment variable, falling back to the current default, e.g.

registry="${OPENCODE_NPM_REGISTRY:-${NPM_CONFIG_REGISTRY:-https://registry.npmjs.org}}"
registry="${registry%/}"

and use $registry for all three URLs. Respecting NPM_CONFIG_REGISTRY (and/or npm_config_registry) matches what npm users expect; a dedicated OPENCODE_NPM_REGISTRY would allow an override for opencode only. Optionally, document it next to --version in the usage text.

Related: with no --version, the installer also fetches https://opencode.ai/update/api/latest/cli/npm. When a version is pinned that call is skipped, so pinning plus a registry override would make the install work entirely offline from opencode.ai (apart from fetching the script itself).

Tested with v2.4.2: with the registry rewritten, installing through an Artifactory npm remote works, including the encoded @opencode%2fcli-linux-x64/<version> metadata check.

Activity

  1. opencodejr commented on Nov 27, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up and the workaround, @fellinga!

    I think this is a duplicate of #57797, which asks the same thing: make the install script use NPM_CONFIG_REGISTRY / npm_config_registry (without the trailing slash) instead of the hardcoded https://registry.npmjs.org. The current script still hardcodes it in the three places you point out: the version check, the @opencode-ai fallback check and the tarball download.

    Related issues and pull requests, ordered by likelihood:

    I'm closing this issue now as a duplicate of #57797. Please add your extra points there: the dedicated OPENCODE_NPM_REGISTRY override, and that a pinned --version means the install never contacts opencode.ai. If you think this isn't a duplicate, reply here and the issue will reopen.

  2. added
    area/install-upgrade
    type/feature
    version/v2
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/install-upgradetype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions