Repository navigation
Npm.outdated() and @npmcli/arborist in src/npm/index.ts ignore user's npm registry config — plugin install hanging in some area #21324
Description
Description
Desc
PR #4958 fixed the hardcoded registry in installation/index.ts (opencode upgrade), but the same problem exists in packages/opencode/src/npm/index.ts — the Npm module used for plugin dependency installation and package outdated checks.
This causes opencode serve to take 5-12 minutes to start when .opencode/plugins/ contains local plugins, because npm package resolution bypasses the user's configured registry (e.g. China mirror) and hits registry.npmjs.org directly.
Affected code
1. Npm.outdated() — hardcoded registry (same as #4830)
// packages/opencode/src/npm/index.ts
export async function outdated(pkg: string, cachedVersion: string): Promise<boolean> {
const response = await fetch(`https://registry.npmjs.org/${pkg}`) // ← hardcoded
...
}2. Npm.add() and Npm.install() — @npmcli/arborist without registry option
const arborist = new Arborist({
path: dir,
binLinks: true,
progress: false,
savePrefix: "",
ignoreScripts: true,
// ← no `registry` option — does not respect ~/.npmrc in all environments
})@npmcli/arborist can read ~/.npmrc in some cases, but in practice it does not pick up the user's registry config when invoked from within the opencode Bun process. Users who set registry=https://registry.npmmirror.com/ in ~/.npmrc still see requests going to registry.npmjs.org.
Impact
- Any user behind a slow/blocked connection to
registry.npmjs.org(common in China, corporate firewalls) experiences 5-12 min startup delay when using plugins GET /global/healthreturnshealthy: trueimmediately, making it appear the server is ready when it isn't — downstream tools that rely on health checks enter a broken state- This affects both local plugins (
.opencode/plugins/) and npm plugins ("plugin": [...]in config)
Suggested fix
Npm.outdated(): Read user's registry config (same approach as PR fix: respect npm registry #4958):import { execSync } from "child_process" function getRegistryUrl(): string { try { return execSync("npm config get registry", { encoding: "utf-8" }).trim() } catch { return "https://registry.npmjs.org" } }
Npm.add()/Npm.install(): Passregistryto Arborist constructor:const registry = getRegistryUrl() const arborist = new Arborist({ path: dir, registry, // ← respect user config ... })
- opencode upgrade has hardcoded registry #4830 — same hardcoded registry problem in
installation/index.ts(fixed by PR fix: respect npm registry #4958)
Plugins
No response
OpenCode version
1.3.17
Steps to reproduce
- Configure npm mirror in
~/.npmrc:registry=https://registry.npmmirror.com/ - Create a workspace with a local plugin:
mkdir -p ~/test-workspace/.opencode/plugins cat > ~/test-workspace/.opencode/plugins/hello.js << 'EOF' export default async (ctx) => { console.log("Hello plugin loaded"); return {}; }; EOF
- Start opencode:
cd ~/test-workspace && opencode serve --port 4096
- In another terminal, monitor the SSE stream:
curl -N http://localhost:4096/event
- Observe:
server.connectedevent takes 5-12 minutes to appear. During this timeGET /global/healthreturns{ healthy: true }, but all other API endpoints are blocked. - Workaround: If you pre-install dependencies manually before starting opencode, it starts in ~10 seconds:
cd ~/test-workspace/.opencode echo '{"dependencies":{"@opencode-ai/plugin":"1.3.17"}}' > package.json npm install && npm install --package-lock-only # Now opencode serve starts in ~10s
Screenshot and/or share link
Operating System
macOS arm64
Terminal
ghostty
Activity
github-actions commentedon Apr 7, 2026
This issue might be a duplicate of existing issues. Please check:
registryconfiguration #21079: .opencode/package-lock.json generated without respecting ~/.npmrcregistryconfiguration — same underlying issue with Arborist ignoring registry settingsThese issues appear to share the same root cause as yours. It may be worth consolidating the discussion there.
junmediatek commentedon Apr 15, 2026
+1
fix: respect npm config cwd for plugin installs
sophymarine commentedon Apr 20, 2026
This looks like the same class of bug in a different place: package tooling should respect the operator’s registry and not hardcode upstream defaults. A useful pattern is to keep network policy outside the app core, then route through a configurable data layer. OpenRegistry takes that approach for company data by exposing 27 government registries through one MCP endpoint, with source-linked records instead of cached mirrors: https://openregistry.sophymarine.com/mcp. It is a good fit whenever registry selection and traceability matter more than a bundled abstraction.
rekram1-node commentedon Apr 20, 2026
fixing rn
micheljung commentedon May 11, 2026
@rekram1-node this does't seem to be fixed yet, but it has been marked as duplicate - of what?
rekram1-node commentedon May 11, 2026
@micheljung see the 2 linked issues, can u tell me more about what issue u are having?
micheljung commentedon May 11, 2026
@rekram1-node I see, it should be fixed in #24001.
I'm behind a custom npm registry, no internet access.
Since I put a tiny local plugin in
~/.config/opencode/pluginopencode takes a long time to start (but it eventually works). In the log I see:opencode is version
1.14.48.I don't have an
~/.npmrc, the registry is specified inNODE_HOME/etc/npmrc.