Link Packages
This document provides instructions on how to create links between packages in the monorepo.
By using the attach
command, you can link packages in the monorepo. This command will add the specified packages to the dependencies
, devDependencies
, peerDependencies
, or optionalDependencies
field in the package.json
file of the target package.
Command
Use the following commands to link packages:
bash
monopkg attach <packages...> [options]
bash
bun x monopkg attach <packages...> [options]
bash
npx monopkg attach <packages...> [options]
bash
yarn dlx monopkg attach <packages...> [options]
Options
-s
,--save
- Add packages as Dependencies.-d
,--dev
- Add packages as devDependencies.-p
,--peer
- Add packages as peerDependencies.-o
,--optional
- Add packages as optionalDependencies.-w
,--workspace
- Root workspace of the packages.-f
,--filter
- Include specific packages.-e
,--exclude
- Exclude specific packages.
Examples
Link ui
package to the web
package as devDependencies
.
bash
monopkg attach ui -f web -d
bash
bun x monopkg attach ui -f web -d
bash
npx monopkg attach ui -f web -d
bash
yarn dlx monopkg attach ui -f web -d
Output
The updated package.json
file of the web
package will look like this:
json
{
"devDependencies": {
"eslint": "^7.32.0",
"ui": "workspace:*"
}
}