Use bun link
in a local directory to register the current package as a "linkable" package.
{
"name": "cool-pkg",
"version": "1.0.0"
}
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.
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
Flags
General & Context
Specify path to config file (bunfig.toml)
Dependency & Scope
Don't install devDependencies
Exclude 'dev', 'optional', or 'peer' dependencies from install
Add to trustedDependencies in the project's package.json and install the package(s)
Lockfile & Persistence
Write a yarn.lock file (yarn v1)
Don't update package.json or save a lockfile
Save to package.json (true by default)
Disallow changes to lockfile
Save a text-based lockfile
Generate a lockfile without installing dependencies
Installation Behavior
Always request the latest versions from the registry & reinstall all dependencies
Skip verifying integrity of newly downloaded packages
Skip lifecycle scripts in the project's package.json (dependency scripts are never run)
Platform-specific optimizations for installing dependencies. Possible values: "clonefile" (default), "hardlink", "symlink", "copyfile"
Networking & Registry
Provide a Certificate Authority signing certificate
The same as `--ca`, but is a file path to the certificate
Use a specific registry by default, overriding .npmrc, bunfig.toml and environment variables
Performance & Concurrency
--concurrent-scripts=<val>
Maximum number of concurrent jobs for lifecycle scripts (default 5)
--network-concurrency=<val>
Maximum number of concurrent network requests (default 48)
Caching
Store & load cached data from a specific directory path
Ignore manifest cache entirely
Output & Logging
Excessively verbose logging
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.