---
title: "Working with Named Registries"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/registries"
image: "https://docs.vlt.io/og/client/registries"
lang: "en"
---

# Working with Named Registries

The vlt client supports working with multiple registries in a variety of ways.

> For a conceptual overview, see [Named Registries](https://docs.vlt.io/concepts/named-registries.md).

## Setting the Registry

**With no configuration, vlt installs through vlt's public npm mirror**, `https://registry.vlt.io/upstream/npm/`, the built-in URL of the [`npm` alias](https://docs.vlt.io/client/registries#npm). Package metadata and tarball requests for bare specs like `vlt install foo` go to `registry.vlt.io` instead of `registry.npmjs.org`, so `vlt install`, `vlx`, `vlt view` and the other read commands work right after installing vlt. See [Public npm Mirror](https://docs.vlt.io/registry/public-mirror.md) for details.

The public mirror is a shared, free service with usage limits. For an account mirror with no usage limits, private packages and access control, run [`vlt setup`](https://docs.vlt.io/client/registries#getting-started-with-vlt-setup) (recommended). To use the public npm registry, or any other registry, instead:

```bash
vlt config set registries.npm=https://registry.npmjs.org/ --config=user
```

The public mirror is read-only. Commands that publish or authenticate (`vlt publish`, `vlt login`, `vlt whoami`, `vlt token`, `vlt dist-tag`, ...) need a registry you configure, and fail with a config error without one:

```
Config Error: Missing registry configuration.

vlt's built-in `npm` registry is a read-only public mirror, so this
command needs a registry you configure. Run `vlt setup` to use your
vlt.io account, pass `--registry=<url>`, or, to publish, set
`publishConfig.registry` in package.json.

See https://docs.vlt.sh/cli for other ways to set a registry.
```

Commands that install packages (`vlt install`, `vlt update`, `vlt uninstall`, `vlt ci`, `vlx`/`vlt exec`) resolve bare specs through the `registries.npm` alias — or, when `default-registry-alias` is set to something else, the alias it names. When `default-registry-alias` names an alias with no URL, they fail with:

```
Config Error: Missing main registry configuration.

Bare specs resolve through the `registries.main` alias
(`default-registry-alias`), which has no URL. Set it with
`vlt config set registries.main=<url>`, or point
`default-registry-alias` at a configured alias.

See https://docs.vlt.sh/cli for other ways to set a registry.
```

There are four ways to configure the registry directly, in increasing order of precedence:

1. **The `vlt.json` in your user config directory**, which applies to every project. Either write it by hand:

   ```json
   {
     "config": {
       "registry": "https://registry.npmjs.org/"
     }
   }
   ```

   or set it with the CLI:

   ```bash
   vlt config set registry=https://registry.npmjs.org/ --config=user
   ```

2. **The `vlt.json` in your project root**, which applies to that project only:

   ```bash
   vlt config set registry=https://registry.npmjs.org/
   ```

3. **The `VLT_REGISTRY` environment variable**, which is handy in CI:

   ```bash
   VLT_REGISTRY=https://registry.npmjs.org/ vlt install
   ```

4. **The `--registry` flag**, for a single command:

   ```bash
   vlt install --registry=https://registry.npmjs.org/
   ```

The `registry` scalar only covers bare specs. `npm:` alias specs, which are common in dependency trees (for example `"string-width-cjs": "npm:string-width@^4.2.0"`), resolve through `registries.npm`, which is vlt's public npm mirror unless you configure it. To keep every install off the public mirror, set `registries.npm`, not only `registry`:

```bash
vlt config set registries.npm=https://registry.npmjs.org/ --config=user
```

### Project vs. user registry configuration

A project's registry configuration always wins over the user-level one. Because `registry` outranks any `registries` alias, that holds even when the two layers use different fields: a project that sets `registries` (or `default-registry-alias`) and no `registry` drops the user-level `registry`, rather than being sent to it.

```json
// ~/.config/vlt/vlt.json
{
  "config": {
    "registry": "https://user/",
    "registries": { "main": "https://main/" }
  }
}
```

```json
// ./vlt.json
{ "config": { "registries": { "npm": "https://project/" } } }
```

> Note: The user level config file uses XDG paths that are OS-specific, the example `~/.config/vlt/vlt.json` path used here might not be the same path used in your system, to learn what is the user level config location for your system, run: `vlt config location --config=user`

In that project, bare specs and account commands resolve to `https://project/`. The user's `main` alias is still merged in and addressable as `main:` in a specifier, or with [`vlt registry main …`](https://docs.vlt.io/client/commands/registry.md) — only the _selection_ is taken over. See [Configuring](https://docs.vlt.io/client/configuring.md) for the full layering rules.

### Saving registries given to install

With `--save-config`, registry and git host options passed on the command line or via `VLT_*` env to `vlt install`, `vlt add` or `vlt update` are saved to the project `vlt.json` after a successful install, so a fresh clone installs with a plain `vlt install`:

```bash title="Terminal"
​​$ vlt install --save-config --registries loc=http://reg.local foo@loc:foo@1.x
```

```json
// ./vlt.json
{ "config": { "registries": { "loc": "http://reg.local/" } } }
```

- Without `--save-config` the options only apply to that run.
- Values already in effect from the user or project `vlt.json` are not copied.
- A different value for the same key in the target file (or its `command.<cmd>` block) is an `ECONFIG` error, nothing is installed. Change it with `vlt config set registries.loc=<url>` first. A missing or invalid name, or a missing value, is an `ECONFIG` error too.
- `--config=user` saves to the user `vlt.json` instead.
- When the project file had no `registry`, `registries` or `default-registry-alias`, the user's `registry` and `default-registry-alias` (with that alias's URL) are copied along, since the project now owns registry selection.
- A `vlt install` run by a vlt script (`vlt run`, `vlt exec`, ...) inherits `--save-config`, but only saves what was given to the parent vlt or set for the child, not config the parent read from its own files.

### Bootstrapping with `vlt login`

If you are starting from nothing, `vlt login` is the guided path. It authenticates against the registry you give it and then writes that registry into your project's `vlt.json`, so subsequent commands are already configured:

```bash
vlt login --registry=https://registry.vlt.io/myorg/
```

Pass `--config=user` to configure it for every project instead.

There can be only one registry configured this way, and it is used as the fallback for all package registry resolutions. Normally, if an internal registry is used for all fetches, it effectively must serve _all_ packages, meaning it has to be a caching proxy, as well as the repository for any of your organization's internal code.

Note that the built-in registry aliases (`npm:`, `gh:`, `jsr:`) and the `@jsr` scope mapping have built-in URLs; `npm:` is vlt's public npm mirror (see [The `npm:` alias](https://docs.vlt.io/client/registries#npm) below). All built-in aliases are overridable within their own map (`registries.npm`, `registries.gh`, `jsr-registries.jsr`, `git-hosts.github`, ...).

## Bare specs and `--default-registry-alias`

A **bare spec** — a dependency written without a registry protocol, like `vlt install foo` or `"foo": "^1.0.0"` in `package.json`, as well as any transitive dependency that omits a registry — resolves its registry in the following order of precedence:

1. a matching `scoped-registries` entry (for scoped names)
2. the `registry` scalar (`--registry` / `VLT_REGISTRY`)
3. `registries[<default-registry-alias>]`

`--default-registry-alias` defaults to `npm`, so by default a bare `foo` resolves through `registries.npm`: vlt's public npm mirror, or the URL you configured (for example with `vlt setup`). Change it to route bare specs (including transitive deps without an explicit registry) through a different alias:

```bash
vlt config set default-registry-alias=main
```

With no config, the `npm` alias is vlt's public npm mirror, so a fresh project resolves bare specs with no setup. An alias named by `default-registry-alias` that has no URL has to be configured before bare specs can resolve.

Note that a project which sets `registries` without also setting `default-registry-alias` gets the default `npm` back, even if your user config points it somewhere else. Set it in the project `vlt.json` to route that project's bare specs through a different alias.

## Getting started with `vlt setup`

`vlt setup` is the onboarding wizard for a vlt.io account. It is optional, since vlt installs public packages through the public mirror without it, but recommended: your account's npm mirror has no usage limits, and the account adds private `@<account>/…` packages, tokens and access control. Sign up or log in at [https://www.vlt.io](https://www.vlt.io/) first, then run:

```bash
vlt setup
```

It authenticates against your account and writes the two account registry aliases into your user `vlt.json`:

```json
{
  "registries": {
    "npm": "https://registry.vlt.io/<account>/npm/",
    "main": "https://registry.vlt.io/<account>/main/"
  }
}
```

- `npm` is the default bare-spec alias, so `vlt install <pkg>` and `vlx` now go through your account's npm mirror instead of the public one.
- `main` is your account's primary private registry (named `main:` to match the service).

The wizard then loops to let you add any additional custom aliases (for partner or team registries), optionally authenticating against each. In a terminal it ends by offering, if needed, to add the global bin folder to your `PATH` (`Setup PATH for global installs? (Y/n)`, see [`vlt setup --path`](https://docs.vlt.io/client/commands/setup.md#add-global-bins-to-your-path)). To run it unattended (no browser auth, no PATH prompt; for example in CI or a setup script):

```bash
vlt setup my-account --yes --registries team=https://registry.example.com/
```

Only the account aliases, aliases passed on the command line, and aliases you type at the prompt are written. Aliases that already live in a `vlt.json` are left where they are, so a project-local alias does not become a global one.

Pass `--config=project` to write to the project's `vlt.json` instead of your user config. If you run `vlt setup` inside a project that configures its own registries, it will say so — the project config takes precedence, so writing your user config would have no effect there.

## Targeting a specific registry

Account and authentication commands (`whoami`, `logout`, `login`, `token`, `access`, `publish`, `unpublish`, `deprecate`, `dist-tag`, `profile`, `ping`) need to know which registry to act against. When you have more than one configured, scope a command to a single alias with [`vlt registry <alias> <command>`](https://docs.vlt.io/client/commands/registry.md):

```bash
# act against the registry configured as `main`
vlt registry main whoami

# list tokens for the `npm` registry
vlt registry npm token list
```

You can also run the top-level command directly (`vlt whoami`). Either way, when the target is ambiguous vlt prompts you to pick a registry on an interactive terminal, and otherwise falls back to [`--default-registry-alias`](https://docs.vlt.io/client/registries#bare-specs-and---default-registry-alias). A `--registry=<url>` on the command line always takes precedence, except that `publish` (and `unpublish` of the package in the current directory) use the package's `publishConfig.registry` when set, with no other registry config needed. The built-in `npm` mirror is read-only, so these commands never select it, and `vlt registry npm <command>` needs a configured `registries.npm`.

## Named Scope Registries (npm Compatibility)

Like the npm client, the vlt client allows you to map a given scope to a specific registry.

For example, you could make it so that all packages whose names start with `@mycompany/...` are served from your internal registry.

This can be a convenient way to make only _certain_ packages come from internal private registries, while all the _other_ packages come from a default public registry, meaning that you do not need to proxy everything.

To do this in vlt, use the `scoped-registries` configuration.

```bash
vlt config set scoped-registries=@mycompany=https://registry.local/
```

When you do this in your project, you will see that it adds the option to a `vlt.json` file in your project root.

```bash
$ cat vlt.json
{
  "scoped-registries": {
    "@mycompany": "https://registry.local/",
  }
}
```

If you run this command multiple times, you can set different registries for various different scopes.

## Registry Aliases

Another way to provide very explicit registry behavior is to use a registry alias.

Similar to how a named package can be aliased to another name and version, the vlt client allows you to indicate that you want a given package to come from a specific named registry.

First, create a registry alias by adding an entry to the `registries` config:

```bash
$ vlt config set registries=bar=https://registry.example.com/
```

This will add the appropriate entry to the `vlt.json` file:

```bash
$ cat vlt.json
{
  "registries": {
    "bar": "https://registry.example.com/"
  }
}
```

Now, if you have this in your `package.json` file:

```json
{
  "dependencies": {
    "bloo": "bar:bloo@1.2"
  }
}
```

then the `bloo` package will always come from my defined `bar:` registry alias.

You can also of course use this to install packages from a known registry by alias on the command line:

```bash
$ vlt install bar:bloo@1.2
```

### Alias names must be unique

Each spec prefix maps to one alias. A name set in more than one of `registries`, `jsr-registries` or `git-hosts` (counting the built-in `gh`, `jsr`, `github`, `gitlab`, `bitbucket` and `gist`), or a built-in protocol name like `file` or `https`, is a config error. Fix it by renaming the alias, or remove it with `vlt config delete <field>.<name>` (`--config=user` for the user config).

### Special Aliases:

#### `npm:`

The `npm:` alias is the default bare-spec alias (see [`--default-registry-alias`](https://docs.vlt.io/client/registries#bare-specs-and---default-registry-alias)). Its built-in URL is vlt's public, read-only npm mirror, `https://registry.vlt.io/upstream/npm/`, so bare specs like `foo@1.2.3` and aliases like `foo@npm:bar@1.2.3` resolve with no configuration. The mirror is a shared service with usage limits, and it only serves reads.

The `registry` scalar (`--registry`, `VLT_REGISTRY`) does not change this alias: it covers bare specs only. `npm:` alias specs, including the ones in your dependencies, keep resolving through `registries.npm`, so with only `registry` set they still go to the public mirror.

The easiest way to change it is [`vlt setup`](https://docs.vlt.io/client/registries#getting-started-with-vlt-setup), which points `registries.npm` at your account's mirror (no usage limits). You can also set it directly, for example to the public npm registry or an internal caching proxy:

```bash
vlt config set registries.npm=https://registry.npmjs.org/
```

> Caution: since the built-in mirror is read-only, `vlt publish` and the account commands never use it. Configure their registry with `publishConfig.registry`, `--registry` or `vlt setup`.

#### `jsr:`

The `jsr:` alias is a special alias that allow you to install packages from [JavaScript Registry (jsr)](https://jsr.io/).

For example, you can install a package from the JSR registry like this:

```bash
$ vlt install jsr:@am/neuralNetwork@1.0.0
```

The `jsr:` alias has a built-in URL (`https://npm.jsr.io/`). Unlike a bare spec, it is resolved from its own alias map and is _not_ affected by the `registry` scalar; to point it at a different host (such as a caching proxy in your organization's network), override it with `--jsr-registries`:

```bash
vlt config set jsr-registries=jsr=https://jsr.local/
```

JSR packages name their own JSR dependencies with `@jsr/*` names (for example `@jsr/std__path`). vlt maps the `@jsr` scope to the `jsr` alias URL by default, so those come from JSR, while the npm dependencies of a JSR package resolve from your configured registry like any other dependency without a prefix. Overriding `jsr-registries.jsr` moves the `@jsr` scope with it, and a `scoped-registries` entry for `@jsr` overrides both. Packages installed through an additional alias in `jsr-registries` still get their `@jsr/*` dependencies from the `@jsr` scope, so map `@jsr` to that host as well if they must come from it.

#### `gh:`

The `gh:` alias is a special alias that allows you to install packages from [GitHub Package Registry](https://docs.github.com/en/packages).

For example, you can install a package from the GitHub package registry like this:

```bash
$ vlt install gh:@octocat/hello-world@1.0.0
```

This will fetch the package from `https://npm.pkg.github.com/` instead of the registry a bare spec would use. Like `jsr:`, the built-in `gh:` URL can be overridden via `--registries`.

### Registry Consistency

A dependency written without a registry prefix resolves from your configuration at every depth of the graph: a matching `scoped-registries` entry, then the `registry` scalar, then `registries[<default-registry-alias>]` (see [Bare specs](https://docs.vlt.io/client/registries#bare-specs-and---default-registry-alias)). The registry of the package that declares it plays no part, which is also how npm, pnpm, Yarn, Bun and Deno resolve dependencies.

Consider a package `foo` that you install from the registry `https://registry.foo.com/` with `vlt install foo:foo@1.2.3`. It depends on a package `bar`, published to that same registry, without any prefix:

```json
{
  "name": "foo",
  "version": "1.2.3",
  "dependencies": {
    "bar": "1.x"
  }
}
```

The `foo:` alias applies to `foo` only, so `bar@1.x` resolves from your default registry. If a _different_ package named `bar` exists there, that one is installed. To keep private packages on their own registry:

1. **Scope your private packages and map the scope.** With `@mycompany/foo` depending on `@mycompany/bar`, a single `scoped-registries` entry sends every `@mycompany/*` package to your registry at any depth, while their public dependencies come from your default registry (in `vlt.json`):

   ```json
   {
     "config": {
       "scoped-registries": {
         "@mycompany": "https://registry.foo.com/"
       }
     }
   }
   ```

2. **Use an alias for an explicit one-off.** `foo:foo@1.2.3` picks the registry for `foo` itself, not for its dependencies.

3. **Use `npm:` inside published packages that must be unambiguous.** A dependency written as `npm:bar@1.x` always resolves through the consumer's `npm` alias.

4. **Use a `registry:` URL when every consumer installs with vlt.** A dependency written as `registry:https://registry.foo.com/#bar@1.x` always resolves from that URL, with no alias or scope mapping on the consumer's side. Other package managers reject this specifier, so keep it to packages that only vlt users install (see [Registry URL Specifiers](https://docs.vlt.io/client/registries#registry-url-specifiers)).

5. **For a registry that hosts everything your project installs**, make it your default registry (`default-registry-alias`, or `registries.npm`), or scope its packages as above.

When a dependency without a prefix is not found on your default registry and the package that declares it came from another one, the error names both registries. To install the dependency from its parent's registry, map its scope in `scoped-registries`, or give that edge an explicit prefix with a [graph modifier](https://docs.vlt.io/client/graph-modifiers.md) in `vlt.json`:

```json
{
  "modifiers": {
    "#foo > #bar": "foo:bar@1.x"
  }
}
```

#### Lockfiles from earlier versions

Earlier versions of vlt resolved the unprefixed dependencies of a package installed through an alias or a scope mapping from that package's registry. A lockfile written that way is not migrated: the next time those dependencies are resolved (after adding or removing a dependency, editing `package.json`, changing the registry configuration, or `vlt update`) they follow the current rule and come from your configuration. To keep one on its previous registry, use a `scoped-registries` entry or a graph modifier as shown above.

### Caution: Registry Aliases Are Not For Published Packages

Except for the `npm:` alias, it is generally _not_ advised to use registry alias specifiers in published package dependencies.

At the time of this writing, only the vlt client supports arbitrary registry alias specifiers, and there is no broad consensus on which aliases point to which registries, or even any clear understanding about how such consensus might be found.

An alias written in a published package resolves through the consumer's `registries` configuration at any depth, so it only works for consumers who define that alias (anyone else gets a config error). The dependencies of the aliased package still resolve from the consumer's configuration, not from the alias.

While they are perfectly safe to use within your own application, they should _not_ be used in library code that you publish for wider consumption by the open source community.

## Registry URL Specifiers

The vlt client supports [`registry:` Dependency Specifiers](https://github.com/npm/rfcs/blob/main/accepted/0035-registry-spec.md). This means that, even without a configured alias, the registry can always be specified explicitly by URL within any context where a dependency is defined.

In fact, this is what registry aliases desugar to, and they have the exact same behavior.

For example, like in the `foo:foo@1` example above, we could have also done:

```bash
$ vlt install "foo@registry:https://foo.com#foo@1"
```

While `registry:` specifiers are quite verbose and ugly, they are also very explicit and can only be interpreted a single way, without requiring any special configuration.

While broad consensus on configuration would not be required in this case, it is still not recommended to use them in published library code, because currently only the vlt client has support for this type of specifier.

We hope that other package managers add support for `registry:` specifiers in the future. If they do, then it will be safe to use them in published open source library code as well.

## See Also

If you are using custom registries, you are very likely going to be interested in setting up [Authentication](https://docs.vlt.io/client/auth.md) at some point.
