Skip to content

fix(plugin): load npm config before Arborist installs#22025

Open
ghost91- wants to merge 2 commits intoanomalyco:devfrom
ghost91-:fix/plugin-npmrc-registry
Open

fix(plugin): load npm config before Arborist installs#22025
ghost91- wants to merge 2 commits intoanomalyco:devfrom
ghost91-:fix/plugin-npmrc-registry

Conversation

@ghost91-
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #21123

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes plugin installs from private npm registries.

After the switch to @npmcli/arborist, OpenCode created Arborist without loading npm config first. That caused plugin installs to ignore .npmrc settings such as scoped registries and fall back to registry.npmjs.org.

This PR loads npm config with @npmcli/config and passes the flattened result into Arborist. Npm.add() loads config from Global.Path.cache, which preserves the previous cache-local .npmrc behaviour. Npm.install(dir) loads config from dir, so local config still works there as well.

Related:

How did you verify your code works?

  1. Added regression tests for:
    • scoped registry config from user .npmrc
    • cache-root .npmrc
    • install-dir .npmrc
  2. Ran:
    • bun test test/npm/index.test.ts
    • bun test test/config/config.test.ts
    • bun test test/plugin/loader-shared.test.ts
    • bun typecheck
  3. Built the patched binary locally and verified that installing a plugin from a private scoped registry now works with .npmrc config.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a potentially related PR:

PR #21697: fix(opencode): resolve npmrc with @npmcli/config
#21697

This PR appears related because it also deals with resolving npm config using @npmcli/config. Since PR #22025 (current) is specifically about loading npm config before Arborist installs for the plugin system, while #21697 may address a similar issue in the main opencode codebase, they could be addressing related or overlapping concerns with npm configuration handling.

Comment thread packages/opencode/package.json Outdated
@cynicalight
Copy link
Copy Markdown

hello, do you know why everybody failed these two test: e2e(linux) and e2e(windows)? 🤣

@cp0213
Copy link
Copy Markdown

cp0213 commented Apr 15, 2026

Can't wait for this PR to be merged! My opencode has been stuck at version 1.3.13 and I haven't been able to update it for days.

@ghost91- ghost91- force-pushed the fix/plugin-npmrc-registry branch from 76589e2 to 95bd891 Compare April 15, 2026 08:36
j4ng5y added a commit to j4ng5y/opencode that referenced this pull request Apr 16, 2026
Load npm config from the active instance/config directory when installing plugin and provider packages so project .npmrc settings and env precedence are preserved for cached installs.

Refs anomalyco#21123, anomalyco#21324, anomalyco#21436, anomalyco#21697, anomalyco#22025.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin install ignores scoped registries from ~/.npmrc and fetches from registry.npmjs.org

3 participants