---
title: "vlt install"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/commands/install"
image: "https://docs.vlt.io/og/client/commands/install"
lang: "en"
---

# vlt install

Usage:

```bash title="Terminal"
$ vlt install [packages ...]
```

Install dependencies into `node_modules`, updating `package.json` and `vlt-lock.json` appropriately.

By default, `vlt install` downloads and extracts packages **without executing lifecycle scripts**—enhancing security by preventing arbitrary code execution during installation. Use [`vlt build`](https://docs.vlt.io/client/commands/build.md) after installation to run scripts selectively.

## What is a Package?

- A folder containing a `package.json` file
- A gzipped tarball containing a folder with a `package.json` file
- A URL that resolves to a gzipped tarball
- A `<name>@<version>` that is published to a configured registry
- A `<name>@<semver-range>` that is published to a configured registry
- A `<name>@<tag>` that points to a package in a configured registry
- A `<name>` by itself, which defaults to using the `latest` tag from a registry
- A `<custom>:<name>@<version>` that points to a custom registry configured in `vlt.json`
- A `registry:URL#<name>@<version>` that points to a custom registry url
- A `<git remote url>` that resolves to a folder with a `package.json` file

## Basic Usage

### Install all dependencies

```bash title="Terminal"
$ vlt install
```

Installs all dependencies from `package.json` without running scripts.

## Adding new packages

Using positional arguments that use the valid package specification described above.

### Registry packages

Installing by name (a **bare spec**) works with no configuration: the built-in `npm` alias is [vlt's public npm mirror](https://docs.vlt.io/registry/public-mirror.md), so package metadata and tarballs come from `registry.vlt.io`. The mirror is read-only and has usage limits; run [`vlt setup`](https://docs.vlt.io/client/registries.md#getting-started-with-vlt-setup) to use your account's npm mirror instead, or set another registry:

```bash title="Terminal"
$ vlt config set registries.npm=https://registry.npmjs.org/
```

`vlt install` (and `vlt update`, `vlt uninstall`, `vlt ci`, `vlx`/`vlt exec`) resolve bare specs through `registries.npm` — or, if you changed `default-registry-alias`, the alias it names — and fail with a config error when that alias has no URL.

```bash title="Terminal"
# Latest version
$ vlt install express

# Scoped packages using semver ranges

$ vlt install @vltpkg/graph@^1.0.0
```

### Aliases

Install multiple versions of the same package side-by-side:

```bash title="Terminal"
# Install react v18 as my-react
$ vlt install my-react@npm:react@18

# Install both major versions under aliased names

$ vlt install react18@npm:react@18 react19@npm:react@19
```

In the `vlt` cli the traditional aliases also enable installing from custom registries:

```bash title="Terminal"
# Install from vlt.json configured custom registry
$ vlt install custom:@org/pkg@^1.0.0

# Install using an aliased name, pointing to a custom registry

$ vlt install pkg@custom:@org/pkg
```

### Git repositories

```bash title="Terminal"
# GitHub shorthand
$ vlt install github:user/repo
$ vlt install github:user/repo#v1.0.0
$ vlt install github:user/repo#semver:^1.0

# Full git URL

$ vlt install git+ssh://git@github.com:user/repo.git

# OR

$ vlt install git+https://github.com/user/repo.git#main

# GitLab

$ vlt install gitlab:user/repo

# Bitbucket

$ vlt install bitbucket:user/repo
```

When using `#semver:<range>`, vlt looks for matching tags/refs in the remote repository.

#### Private GitHub repositories

A `github:` dependency with a ref (eg `github:user/repo#v1.0.0`, or a `git+ssh://git@github.com:user/repo.git#v1.0.0` url) is downloaded as an archive from `codeload.github.com`, without a token, so a private repository fails with a 404. Download it from the GitHub REST API instead: point the `github` archive template at the API, then add a GitHub token that can read the repository's contents:

```bash title="Terminal"
$ vlt config set 'git-host-archives.github=https://api.github.com/repos/$1/$2/tarball/$committish'
$ vlt token add --registry=https://api.github.com
```

`vlt config set` saves the template to the project `vlt.json`, so `vlt ci` and everyone else on the project use it too. `vlt token add` prompts for the token and keeps it in the vlt keychain; it is only sent to `api.github.com`, which redirects to a short-lived download url. See [`--git-host-archives`](https://docs.vlt.io/client/configuring.md#-anametemplate---git-host-archivesnametemplate).

A `git+https://github.com/user/repo.git#v1.0.0` url is cloned with git instead, using your git credentials.

#### Git dependencies

A git dependency is locked to the commit its ref, `#semver:` range or default branch points to. For a hosted one (`github:`, `gitlab:`, `bitbucket:` or `gist:`, eg `github:user/repo`, `github:user/repo#main` or `github:user/repo#main::path:packages/x`), `vlt-lock.json` records the host's archive at that commit, and its integrity; with `::path:`, installs unpack only that directory. Resolving a `#semver:` range still needs git, to list the tags. Others (eg `git+https://` urls) are cloned: the lockfile records `<repo url>#<sha>`, and installs fetch that commit. So is a hosted one without a ref, or with `::path:` or `#semver:`, whose repo has submodules (archives leave them out) or whose archive can't be fetched, like a private repo.

- `vlt install` keeps the locked commit after the branch moves.
- `vlt ci` and `--frozen-lockfile` install exactly that commit.
- `vlt update` moves it to the ref's current commit; [`vlt update <name>`](https://docs.vlt.io/client/commands/update.md) moves only that one.

To pin a commit in `package.json`, use it as the ref: `github:user/repo#<sha>`.

A host can re-pack an archive: same commit, other bytes. Installing it from the lockfile then fails its integrity check, and the error says so, with the dependency's name. To lock the new archive, run [`vlt cache delete "<url>"`](https://docs.vlt.io/client/commands/cache.md#delete), then [`vlt update <name>`](https://docs.vlt.io/client/commands/update.md): only that dependency is resolved again, everything else keeps its locked version. vlt never clones that commit instead: that would skip the integrity check.

Lockfiles from older vlt versions lock git dependencies to a ref, not a commit. `vlt install` re-resolves those entries and locks the commit their ref points to now. One it can't resolve (offline, host down, ref gone, or a host that doesn't answer within 10 seconds) is kept as it is, with a warning, and tried again on the next install. `vlt ci`, `--frozen-lockfile` and `--expect-lockfile` install them as they are: once the ref moved, a hosted one can fail its integrity check, so run `vlt install` once and commit the lockfile. Older vlt versions may install a git dependency at its ref's current commit, even from a newer lockfile: after such an install, or restoring its `node_modules` (eg from a CI cache), run `vlt ci` once.

### Tarballs

```bash title="Terminal"
# Local tarball
$ vlt install ./package.tgz

# Remote tarball

$ vlt install https://example.com/package.tgz
```

### Local directories

```bash title="Terminal"
# Relative path
$ vlt install ./my-local-package

# Install from parent directory

$ vlt install ../shared-lib
```

### Workspaces

When a name with no range resolves to a workspace, vlt links it and saves `workspace:*` to `package.json`. Use `my-lib@workspace:*` to require the workspace.

```bash title="Terminal"
$ vlt install my-lib
```

## Options

### Dependency type flags

| Flag              | Short | Description                                  |
| ----------------- | ----- | -------------------------------------------- |
| `--save-prod`     | `-P`  | Add to `dependencies` (default)              |
| `--save-dev`      | `-D`  | Add to `devDependencies`                     |
| `--save-optional` | `-O`  | Add to `optionalDependencies`                |
| `--save-peer`     |       | Add to `peerDependencies`                    |
| `--save-types`    |       | Add matching `@types/*` to `devDependencies` |

[`--save-types`](https://docs.vlt.io/client/configuring.md#--save-types) skips packages that ship their own types:

```bash title="Terminal"
# express ships no types: adds @types/express to devDependencies too
$ vlt install express --save-types

# zod ships its own types: adds zod only

$ vlt install zod --save-types
```

### Config options

| Flag            | Description                                                                                                                                                                                                                      |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--save-config` | Save registry and git host options given on the command line or via env to the project `vlt.json` (user one with `--config=user`), see [Registries](https://docs.vlt.io/client/registries.md#saving-registries-given-to-install) |

### Lockfile options

| Flag                | Description                                                         |
| ------------------- | ------------------------------------------------------------------- |
| `--frozen-lockfile` | Fail if lockfile is missing or out of sync with `package.json`      |
| `--expect-lockfile` | Fail if lockfile is missing or outdated                             |
| `--lockfile-only`   | Update only `vlt-lock.json` and `package.json`, skip `node_modules` |

### Script execution

| Flag                         | Description                                                                          |
| ---------------------------- | ------------------------------------------------------------------------------------ |
| `--allow-scripts=<selector>` | Allow specific packages to run lifecycle scripts during install; saved to `vlt.json` |

```bash title="Terminal"
# Allow specific packages to run scripts during install
$ vlt install --allow-scripts="#esbuild, #node-gyp"

# Allow only direct dependencies to run scripts

$ vlt install --allow-scripts=":root > *"
```

`vlt install` and `vlt update` save `--allow-scripts` (or `VLT_ALLOW_SCRIPTS`) to the project `vlt.json` after a successful install. When another query is stored, it is kept and a hint says so: change it with [`vlt build`](https://docs.vlt.io/client/commands/build.md#allow-scripts). `--lockfile-only` saves nothing. An invalid query fails before anything is installed.

### Agent skills

| Flag                        | Description                                                                                                             |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `--allow-skills=<selector>` | Link the agent skills of matching packages into the agent skill dirs after install (default: none); saved to `vlt.json` |
| `--skills-dir=<path>`       | Dirs to link agent skills into, replacing detection (`--skills-dir=` links nothing)                                     |

```bash title="Terminal"
# Link the agent skills of direct dependencies
$ vlt install --allow-skills=":root > *"
# Link one skill of one package
$ vlt install --allow-skills="#agent-browser:skill(agent-browser)"
```

See [`vlt skills`](https://docs.vlt.io/client/commands/skills.md).

### Registry options

| Flag              | Description                                    |
| ----------------- | ---------------------------------------------- |
| `--tag=<tag>`     | Default dist-tag to use (default: `latest`)    |
| `--before=<date>` | Install relative to the provided ISO 8601 date |

```bash title="Terminal"
# Install from beta channel
$ vlt install express --tag=beta

# Install versions published before a specific date

$ vlt install lodash --before="2024-01-01"
```

### Workspace options

| Flag                        | Short | Description                                                                |
| --------------------------- | ----- | -------------------------------------------------------------------------- |
| `--workspace=<ws>`          | `-w`  | Limit operation to specific workspaces                                     |
| `--workspace-group=<group>` |       | Operate on named workspace groups                                          |
| `--no-migrate-workspaces`   |       | Don't save workspaces to `vlt.json` or rewrite references to `workspace:*` |

```bash title="Terminal"
# Install in specific workspace
$ vlt install -w packages/core lodash

# Install in workspace group

$ vlt install --workspace-group apps express
```

### Global options

| Flag                      | Short | Description                                                                                                         |
| ------------------------- | ----- | ------------------------------------------------------------------------------------------------------------------- |
| `--global`                | `-g`  | Install into the global project, see [Global installs](https://docs.vlt.io/client/commands/install#global-installs) |
| `--global-dir=<path>`     |       | Location of the global project (default: `vlt/global` in the XDG data dir)                                          |
| `--global-bin-dir=<path>` |       | Where bins of global packages are linked (default: next to `vlt`)                                                   |

## Global installs

Install command line tools once, for use anywhere, with `-g`:

```bash title="Terminal"
$ vlt install -g eslint

# install a local tool

$ vlt install -g ./my-tool
```

For a walkthrough and how to version your global tools, see [Global Installs](https://docs.vlt.io/client/global-installs.md) and its [best practices](https://docs.vlt.io/client/global-installs.md#best-practices).

Global packages live in a regular vlt project at `--global-dir` (`vlt/global` in the XDG data directory by default, e.g. `~/.local/share/vlt/global` on Linux):

- each package gets its own workspace, `packages/<name>-ws` (`packages/@scope+name-ws` for scoped packages), with the package as its only dependency
- the project has its own `vlt-lock.json` and `node_modules`
- bins of global packages are linked next to `vlt` itself (the folder your shell found `vlt` in), so they run right away. If that folder isn't writable, vlt uses `~/.local/bin` when it's in your `PATH` (not on Windows), else (or when `vlt` wasn't run from your `PATH`) `<global-dir>/bin`, and prints the line that adds it to your `PATH`. Set `--global-bin-dir` to pick the folder. Or run [`vlt setup --path`](https://docs.vlt.io/client/commands/setup.md#add-global-bins-to-your-path) (`vlt setup` offers it at its end); in a terminal, `vlt install -g` offers to do it once (answer `n` and it won't ask again). `--yes` adds it without asking.

The current project is never read or changed by a global install, including its `vlt.json`. `global`, `global-dir` and `global-bin-dir` can be set on the command line, via env (`VLT_GLOBAL`, `VLT_GLOBAL_DIR`, `VLT_GLOBAL_BIN_DIR`) or in the user config.

With Node.js from the nodejs.org macOS installer, `vlt` is in a root-owned `/usr/local/bin`, so bins usually go to `~/Library/Application Support/vlt/global/bin`. Run `vlt setup --path`, use Node.js from Homebrew, nvm or fnm, or set `--global-bin-dir` to a folder in your `PATH`. A `--global-bin-dir` with spaces needs no escaping in the user config (quote it on the command line as usual).

A package name with no version installs the `latest` dist-tag (or `--tag`), like `npm install -g`, so re-running it upgrades. Use a version or range to pin one instead.

```bash title="Terminal"
# upgrade to latest
$ vlt install -g eslint

# pin a version range

$ vlt install -g eslint@9

# list global packages

$ vlt ls -g

# run their install scripts

$ vlt build -g

# remove a global package and its bins

$ vlt uninstall -g eslint
```

Running `vlt install -g` with no packages re-installs the global project and re-links all bins into the current bin folder, removing the ones vlt linked into folders it used before (e.g. under another Node.js version).

A bin name already in the bin folder (linked by another global package, or a file not created by vlt) is skipped with a warning. Use `--force` to overwrite it. Outside `<global-dir>/bin`, `--force` only replaces links, never plain files or the running `vlt`.

Like any install, scripts of global packages are not run, use `vlt build -g` to run them.

`--workspace`, `--workspace-group` and `--lockfile-only` are not supported with `-g`, and the dependency type flags (`--save-dev`, `--save-types`, etc.) are ignored. `-g` is supported by `install`, `uninstall`, `list`, `query` and `build`.

### Updating vlt

`vlt install -g vlt` updates the `vlt` your shell runs (the one in your `PATH`), the way it was installed:

- installed with npm (e.g. by the install script): runs that npm, `npm install -g vlt@<version>`
- installed as a global package: re-installs it like any global package
- installed some other way: says how to update it instead (e.g. `brew upgrade vlt`)

If vlt can't write where it is installed, it installs itself as a global package instead and links its bins like any other. The old `vlt` keeps running until that folder comes before it in your `PATH`.

A bare `vlt` never downgrades: when `latest` is older than the running `vlt`, it says so. Use `vlt@latest` or a version to install it anyway.

```bash title="Terminal"
$ vlt install -g vlt
$ vlt install -g vlt@latest
```

## Phased Package Installations

Traditional package managers run lifecycle scripts automatically during install—a security risk that allows malicious packages to execute arbitrary code.

`vlt` separates installation into two distinct phases:

1. **Install phase**: Downloads and extracts packages (no scripts)
2. **Build phase**: Runs lifecycle scripts for selected packages

```bash title="Terminal"
# Phase 1: Install packages safely
$ vlt install

# Phase 2: Build with control over what runs

$ vlt build
```

This separation enables you to:

- Inspect dependencies before any code execution
- Selectively allow scripts using DSS queries
- Protect against supply chain attacks

By default, `vlt build` uses `:scripts:not(:built):not(:malware)` which excludes packages with known malware alerts. `vlt build <query>` saves the query as `allow-scripts`, so later installs run those scripts.

For more details, see the [`vlt build`](https://docs.vlt.io/client/commands/build.md) documentation.

## Graph Modifiers

Graph Modifiers provide precise control over dependency resolution using [Dependency Selector Syntax (DSS)](https://docs.vlt.io/client/commands/query.md). Configure them in your `vlt.json`:

```json title="vlt.json"
{
  "modifiers": {
    "#react": "^19",
    ":root > #webpack > #browserslist": "^4.23.0"
  }
}
```

### Override all instances

Pin a package version across the entire dependency graph:

```json title="vlt.json"
{
  "modifiers": {
    "#lodash": "^4.17.21"
  }
}
```

### Override transitive dependencies

Target specific dependency paths:

```json title="vlt.json"
{
"modifiers": {
  ":root > #webpack > #terser-webpack-plugin > #terser": "^5.31.0"
}
}
```

When multiple selectors match, the most specific one wins.

For more details on Graph Modifiers, see the [Graph Modifiers](https://docs.vlt.io/client/graph-modifiers.md) documentation.

## Peer Dependencies

vlt handles peer dependencies by isolating their contexts, allowing multiple versions of the same package to coexist when necessary. When different parts of your dependency tree require incompatible peer versions, vlt automatically subdivides the graph into separate peer dependency contexts.

**Key behavior:** vlt always attempts to use a single version of a package for peer dependencies. When that's not possible, it duplicates packages as needed, storing them in separate locations within `node_modules/.vlt/` and linking appropriately so each package resolves to its correct peer version.

This happens automatically during `vlt install`—no configuration required.

For more details, see the [Peer Dependencies](https://docs.vlt.io/client/peer-dependencies.md) documentation.

## Notes

- Running `vlt install` with no arguments installs all dependencies from `package.json`
- The lockfile (`vlt-lock.json`) ensures reproducible installs across environments
- Workspaces read from `package.json` or `pnpm-workspace.yaml` are saved to `vlt.json` (not with `--frozen-lockfile` / `--expect-lockfile`), see [Workspaces](https://docs.vlt.io/client/workspaces.md#saving-workspaces-to-vltjson)
- Use [`vlt ci`](https://docs.vlt.io/client/commands/ci.md) in CI pipelines: removes `node_modules`, installs exactly from `vlt-lock.json` (like `--expect-lockfile`) and, like `vlt install`, runs no dependency lifecycle scripts unless `--allow-scripts` is set; run `vlt build` after to build packages
- With `vlt-lock.json` and every registry package cached, `--frozen-lockfile` makes no registry requests (git deps may still clone). Registry and cache come from `vlt.json`, `VLT_*` env vars or flags; `.npmrc` and `npm_config_*` aren't read. [Telemetry](https://docs.vlt.io/client/configuring.md#--telemetry) is still sent unless disabled.
- Peer dependencies are handled automatically with context isolation when version conflicts arise

## Local directories (Linked Folders)

```bash title="Terminal"
# Relative path
$ vlt install ./my-local-package

# Install from parent directory

$ vlt install ../shared-lib
```

Local directories can be symlinked to a project via the `file:` protocol. Note that these differ from local tarballs (`file:./pkg.tgz`) which are extracted and treated as immutable.

### Installing from within a Linked Folder

When you `cd` into a linked folder and run `vlt install`, the vlt cli allows you to add dependencies to that folder's `package.json`:

```bash title="Terminal"
# Project has: "my-lib": "file:./libs/my-lib"

$ cd libs/my-lib $ vlt install lodash@^4.17.0

# Adds lodash to libs/my-lib/package.json
```

`vlt` detects your current working directory relative to the project root and targets the appropriate `package.json`.

Note: to use `vlt install` or `vlt uninstall` to manage dependencies of a local linked directory, that folder needs to be already in the chain of dependencies of either the root project or one of its workspaces in order for the `vlt` cli to properly manage the operation.

### Relative paths in Linked Folders

File specs resolve relative to the linked folder's location:

```bash title="Terminal"
# From libs/my-lib, reference ../shared
$ cd libs/my-lib
$ vlt install file:../shared
```

## Aliases

```
i, add
```
