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
Configuration
Specify path to config file (bunfig.toml)
Use a specific registry by default, overriding .npmrc, bunfig.toml and environment variables
Lockfile Management
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
Always request the latest versions from the registry & reinstall all dependencies
Save a text-based lockfile
Generate a lockfile without installing dependencies
Dependency Management
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)
Caching and Performance
Store & load cached data from a specific directory path
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)
Platform-specific optimizations for installing dependencies. Possible values: "clonefile" (default), "hardlink", "symlink", "copyfile"
Verification and Security
Provide a Certificate Authority signing certificate
The same as `--ca`, but is a file path to the certificate
Skip verifying integrity of newly downloaded packages
Logging and Output
Excessively verbose logging
Installation Behavior
Skip lifecycle scripts in the project's package.json (dependency scripts are never run)
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