oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.2k stars 2.77k forks source link

Bun auto-install does not leverage the registry settings from .bunfig.toml #11434

Open uanid opened 5 months ago

uanid commented 5 months ago

What version of Bun is running?

1.1.10

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

  1. delete node_modules dir
  2. Set up private registry configuration in .bunfig.toml
  3. Import a private module in entry.ts
  4. $ bun run entry.ts

My .bunfig.toml

[install]
  [install.scopes]
    [install.scopes."@myorg"]
      token = "redacted"
      url = "https://npm.pkg.github.com/"
    [install.scopes."@myorg-devops"]
      token = "redacted"
      url = "https://myorg-devops-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-npm-packages/"
    [install.scopes."@myorg-platform"]
      token = "redacted"
      url = "https://myorg-platform-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-platform/"

Entry.ts

import {GitLabClient} from '@myorg-devops/gitlab@^1.0.0';
import {S3} from '@myorg-devops/aws@^1.32.1';

What is the expected behavior?

Bun resolves private modules.

What do you see instead?

bun run task-definitions/bitter/deploy/DeployBaseInfra.ts                                                                        ✔ 
  🔍 @myorg-devops/gitlab [1/1] 
error: package "@myorg-devops/gitlab" not found registry.npmjs.org/@myorg-devops%2fgitlab 404
error: Cannot find module "@myorg-devops/gitlab@^1.0.0" from "/Users/musong/deploy/DeployBaseInfra.ts"

Bun v1.1.10 (macOS arm64)

Additional information

I confirmed that $ bun install correctly accesses my private registry.

The issue only occurs when using the $ bun run command.

Additionally, the problem persists even with the configuration set up as follows:

[install]
  [registry]
      token = "redacted"
      url = "https://myorg-devops-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-npm-packages/"
sirenkovladd commented 5 months ago

https://bun.sh/docs/runtime/bunfig#install-scopes

[install.scopes.myorg]
token = "redacted"
url = "https://npm.pkg.github.com/"
[install.scopes."myorg-devops"]
token = "redacted"
url = "https://myorg-devops-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-npm-packages/"
[install.scopes."myorg-platform"]
token = "redacted"
url = "https://myorg-platform-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-platform/"
uanid commented 5 months ago

@sirenkovladd

https://bun.sh/docs/runtime/bunfig#install-scopes

[install.scopes.myorg]
token = "redacted"
url = "https://npm.pkg.github.com/"
[install.scopes."myorg-devops"]
token = "redacted"
url = "https://myorg-devops-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-npm-packages/"
[install.scopes."myorg-platform"]
token = "redacted"
url = "https://myorg-platform-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-platform/"

I understand that the @ prefix is not necessary. However, $ bun install works fine in my computer even with the @ prefix.

Additionally, despite replacing the default registry with my private registry, I confirmed through the error message that API requests are still being sent to registry.npmjs.org.

[install]
  [registry]
      token = "redacted"
      url = "https://myorg-devops-12345678.d.codeartifact.ap-northeast-1.amazonaws.com/npm/myorg-npm-packages/"