You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] .opencode/package-lock.json generated without respecting ~/.npmrc registry configuration #21079
When opencode generates the .opencode/package-lock.json file , it does not respect the registry configuration specified in the user's ~/.npmrc file. The generated package-lock.json appears to use default npm registry settings instead of user-configured values.
Expected Behavior
When generating .opencode/package-lock.json, opencode should read and respect the npm repository configuration from ~/.npmrc, including:
Custom registry URLs
Any other relevant npm configuration
Actual Behavior
The generated .opencode/package-lock.json does not reflect the user's ~/.npmrc configuration. It seems to ignore the registry field entirely when resolving package dependencies.
Plugins
omo
OpenCode version
1.3.15
Steps to reproduce
Use the latest version of opencode
Run opencode command that triggers package-lock.json generation
I have both package-lock.json and bun.lock in my .opencode folder now, and the package-lock.json isn't added to .gitignore in contrast to bun.lock. This change feels unintentional 🤔
Reacted by Daniel, Pedro Sanchez, Anastasia Stowers, Rohit Choudhari, Abe Isleem, Joscha Götzer, Dorian Karter and Jorge Pedroso
This blocks us from upgrading OpenCode, as registry.npmjs.org is blocked by Firewall and we must proxy every NPM request through our own registry. If the value in .npmrc or bunfig is not respected, we have a huge problem. It is also news to me that the ~/.config/opencode/package.json now suddenly has some kind of weight in the whole process, I thought it was mostly ignored and just relevant for custom plugin/*s 🤔
The root cause is straightforward: Npm.add() and Npm.install() in packages/opencode/src/npm/index.ts create new Arborist({...}) without passing registry. Arborist doesn't discover it on its own (that's @npmcli/config's job inside npm CLI), so it falls back to the hardcoded default https://registry.npmjs.org. Same story for outdated() which has a hardcoded fetch() to registry.npmjs.org.
This completely breaks corporate/airgapped environments where registry.npmjs.org is blocked by firewall.
Suggested fix (minimal, ~20 lines)
Read registry from the same sources Bun and npm already use. No heavy deps needed. ini is already a transitive dep via Arborist.
import{parseasparseIni}from"ini"import{parseasparseToml}from"smol-toml"// or skip if bunfig support not desiredimport{readFileSync}from"fs"import{join}from"path"import{homedir}from"os"functiongetRegistry(): string{// 1. env var (set by both npm and bun from their respective configs)if(process.env.npm_config_registry)returnprocess.env.npm_config_registry// 2. ~/.npmrctry{constrc=parseIni(readFileSync(join(homedir(),".npmrc"),"utf8"))if(rc.registry)returnrc.registry}catch{}// 3. bunfig.toml (or skip if bunfig support not desired)try{consttoml=parseToml(readFileSync(join(homedir(),"bunfig.toml"),"utf8"))if(toml.install?.registry)returntoml.install.registry}catch{}return"https://registry.npmjs.org"}
Then:
Pass registry: getRegistry() to every new Arborist() call
Use getRegistry() in outdated() instead of the hardcoded URL
Additional bug: outdated() hardcodes registry
Even with the Arborist fix, outdated() has a separate hardcoded fetch:
update to 1.4.8, ~/.config/opencode/package-lock.json has the same problem
and the startup speed has slowed down significantly, probably due to slower dependency parsing
@rekram1-node Just installed the update and tried to install a new plugin, got 403. Upon inspection of the log, it seems the opencode tried to run GET https://registry.npmjs.org/<plugin-repo>, which seems like the registry is hard-coded, and it isn't getting the registry from .npmrc.
can't use company mirror registry config in my `$HOME/.npmrc`,
Is there a temporary workaround for this problem?
My temporary workaround is here.
### General Plugin Installation Guide
**Variables:**
* `<REGISTRY_URL>`: Your internal package registry URL (e.g., `https://nexus.your-company.com/repository/npm`)
* `<PLUGIN_NAME>`: The target plugin you wish to install
---
**Installation Steps:**
1. **Retrieve the Tarball URL:**
Fetch the package metadata from the registry to get the latest tarball URL:
* Perform a `GET` request to: `<REGISTRY_URL>/<PLUGIN_NAME>`
* Check the `dist-tags` object in the JSON response. Select the `latest` version if it is available; if not, select the `experimental` version.
* Extract the `dist.tarball` URL for the chosen version.
2. **Download and Copy the Plugin:**
* Download the tarball from the extracted URL and extract its contents.
* Copy the `package/dist/index.js` file to your opencode configuration directory as: `~/.config/opencode/<PLUGIN_NAME>.js`
3. **Update the Configuration:**
* Open the `~/.config/opencode/opencode.json` file.
* Add `"./<PLUGIN_NAME>.js"` to the `"plugin"` array. If the entry already exists, you can skip this step.
4. **Finalization:**
* Once the process is complete, output the following message to the user:
> *"Restart opencode to apply the changes."*
reposting from the discord so people can find it -> local-alias@tarball-url should work for those who can't wait/need it right meow. somewhat contrived but eg.
Activity
FurryWolfX commentedon Apr 5, 2026
I see opencode previously generated bun.lock - are you planning to migrate to npm?
[-][Bug] .opencode/package-lock.json generated without respecting ~/.npmrc repo configuration[/-][+][Bug] .opencode/package-lock.json generated without respecting ~/.npmrc `registry` configuration[/+]FurryWolfX commentedon Apr 6, 2026
The
Arboristinstance inpackages/opencode/src/npm/index.tsis created without passing theregistryoption:Without explicit
registryconfiguration,@npmcli/arboristdefaults tohttps://registry.npmjs.orgregardless of any.npmrcsettings.Impact
registry.npmjs.orgcannot use opencode effectivelynpm installdirectlyProposed Solution
Use
@npmcli/configto read the.npmrcand pass the registry to Arborist:Alternatively, read the
registrydirectly from the.npmrcfile and pass it to Arborist.kdybicz commentedon Apr 6, 2026
I have both
package-lock.jsonandbun.lockin my.opencodefolder now, and thepackage-lock.jsonisn't added to.gitignorein contrast tobun.lock. This change feels unintentional 🤔JosXa commentedon Apr 7, 2026
This blocks us from upgrading OpenCode, as registry.npmjs.org is blocked by Firewall and we must proxy every NPM request through our own registry. If the value in .npmrc or bunfig is not respected, we have a huge problem. It is also news to me that the ~/.config/opencode/package.json now suddenly has some kind of weight in the whole process, I thought it was mostly ignored and just relevant for custom
plugin/*s 🤔JosXa commentedon Apr 7, 2026
Analysis & suggested fix
The root cause is straightforward:
Npm.add()andNpm.install()inpackages/opencode/src/npm/index.tscreatenew Arborist({...})without passingregistry. Arborist doesn't discover it on its own (that's@npmcli/config's job inside npm CLI), so it falls back to the hardcoded defaulthttps://registry.npmjs.org. Same story foroutdated()which has a hardcodedfetch()toregistry.npmjs.org.This completely breaks corporate/airgapped environments where
registry.npmjs.orgis blocked by firewall.Suggested fix (minimal, ~20 lines)
Read registry from the same sources Bun and npm already use. No heavy deps needed.
iniis already a transitive dep via Arborist.Then:
registry: getRegistry()to everynew Arborist()callgetRegistry()inoutdated()instead of the hardcoded URLAdditional bug:
outdated()hardcodes registryEven with the Arborist fix,
outdated()has a separate hardcoded fetch:This also needs to use the configured registry.
cc @thdxr @rekram1-node
FurryWolfX commentedon Apr 17, 2026
update to 1.4.8,
~/.config/opencode/package-lock.jsonhas the same problemand the startup speed has slowed down significantly, probably due to slower dependency parsing
kewalpasad commentedon Apr 20, 2026
@rekram1-node Thanks for taking care of this bug is it included in 1.14.19 release?
kewalpasad commentedon Apr 20, 2026
@rekram1-node Just installed the update and tried to install a new plugin, got 403. Upon inspection of the log, it seems the opencode tried to run
GET https://registry.npmjs.org/<plugin-repo>, which seems like the registry is hard-coded, and it isn't getting the registry from .npmrc.ghost91- commentedon Apr 21, 2026
@kewalpasad The issue is not fixed yet, only some preliminary work has been done.
hchangjae commentedon Apr 21, 2026
1.14.19 same here
cp0213 commentedon Apr 22, 2026
1.14.20 same issue
can't use company mirror registry config in my
$HOME/.npmrc,Is there a temporary workaround for this problem?
hchangjae commentedon Apr 22, 2026
My temporary workaround is here.
Propmt to your opencode agent
rilez commentedon Apr 22, 2026
reposting from the discord so people can find it -> local-alias@tarball-url should work for those who can't wait/need it right meow. somewhat contrived but eg.
{ "plugin": [ "antigravity-auth@https://registry.npmjs.org/opencode-antigravity-auth/-/opencode-antigravity-auth-1.6.0.tgz" ] }works the same for private registries