Bun

bun link

Use bun link in a local directory to register the current package as a "linkable" package.

cd /path/to/cool-pkg
cat package.json
{
  "name": "cool-pkg",
  "version": "1.0.0"
}
bun link
bun link v1.x (7416672e)
Success! Registered "cool-pkg"

To use cool-pkg in a project, run:
  bun link cool-pkg

Or add it in dependencies in your package.json file:
  "cool-pkg": "link:cool-pkg"

This package can now be "linked" into other projects using bun link cool-pkg. This will create a symlink in the node_modules directory of the target project, pointing to the local directory.

cd /path/to/my-app
bun link cool-pkg

In addition, the --save flag can be used to add cool-pkg to the dependencies field of your app's package.json with a special version specifier that tells Bun to load from the registered local directory instead of installing from npm:

{
  "name": "my-app",
  "version": "1.0.0",
  "dependencies": {
    "cool-pkg": "link:cool-pkg"
  }
}

CLI Usage

$bun link <packages>

Flags

Configuration

-c,--config=<val>
Specify path to config file (bunfig.toml)
--registry=<val>
Use a specific registry by default, overriding .npmrc, bunfig.toml and environment variables

Lockfile Management

-y,--yarn
Write a yarn.lock file (yarn v1)
--no-save
Don't update package.json or save a lockfile
--save
Save to package.json (true by default)
--frozen-lockfile
Disallow changes to lockfile
-f,--force
Always request the latest versions from the registry & reinstall all dependencies
--save-text-lockfile
Save a text-based lockfile
--lockfile-only
Generate a lockfile without installing dependencies

Dependency Management

-p,--production
Don't install devDependencies
--omit=<val>
Exclude 'dev', 'optional', or 'peer' dependencies from install
--trust
Add to trustedDependencies in the project's package.json and install the package(s)

Caching and Performance

--cache-dir=<val>
Store & load cached data from a specific directory path
--no-cache
Ignore manifest cache entirely
--concurrent-scripts=<val>
Maximum number of concurrent jobs for lifecycle scripts (default 5)
--network-concurrency=<val>
Maximum number of concurrent network requests (default 48)
--backend=<val>
Platform-specific optimizations for installing dependencies. Possible values: "clonefile" (default), "hardlink", "symlink", "copyfile"

Verification and Security

--ca=<val>
Provide a Certificate Authority signing certificate
--cafile=<val>
The same as `--ca`, but is a file path to the certificate
--no-verify
Skip verifying integrity of newly downloaded packages

Logging and Output

--silent
Don't log anything
--verbose
Excessively verbose logging
--no-progress
Disable the progress bar
--no-summary
Don't print a summary

Installation Behavior

--dry-run
Don't install anything
--ignore-scripts
Skip lifecycle scripts in the project's package.json (dependency scripts are never run)

Global Installation

-g,--global
Install globally

Working Directory

--cwd=<val>
Set a specific cwd

Help

-h,--help
Print this help menu

Examples

Directory should contain a package.json.
bun link
Add a previously-registered linkable package as a dependency of the current project.
bun link <package>
Full documentation is available at https://bun.sh/docs/cli/link