Skip to content

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

Open
thdxr wants to merge 1 commit intodevfrom
npmcli-config
Open

fix(opencode): resolve npmrc with @npmcli/config#21697
thdxr wants to merge 1 commit intodevfrom
npmcli-config

Conversation

@thdxr
Copy link
Copy Markdown
Member

@thdxr thdxr commented Apr 9, 2026

Summary

  • replace the custom npmrc loader with @npmcli/config so Arborist uses npm's project, user, global, and env resolution rules
  • keep the npm integration behind Effect services with promise facades, but remove the previous config caching to make the flow easier to follow
  • add focused tests covering project config selection from .opencode, env precedence, and reload behavior

Testing

  • bun typecheck
  • bun test "test/npm.test.ts" "test/npm/config.test.ts"

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@ghost91-
Copy link
Copy Markdown
Contributor

I hit the same underlying issue while debugging plugin installs from private scoped registries.

I opened #22025 from a slightly different angle and verified it locally against a real ~/.npmrc-based private registry setup. From my reading, this PR should address the same main problem.

One small behaviour difference I noticed: my patch keeps Npm.add() config resolution rooted at Global.Path.cache, mainly to preserve the previous cache-local .npmrc behaviour. This PR seems to resolve config relative to the package install dir instead.

If this PR lands, I’m happy to close #22025 and defer to this approach.

@Vivienb
Copy link
Copy Markdown

Vivienb commented Apr 15, 2026

Hello, as I'm on a corporate network, without the correct settings (npm configuration, environment variables), the latest versions are practically unusable with plugins and even LSPs. Would it be possible to quickly merge this PR? Thank you!

@junmediatek
Copy link
Copy Markdown
Contributor

@thdxr
Would it be possible to quickly merge this PR? Thank you!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants