Like lerna add but does just the symlinking, works on CLI bins too

Β§ Quick Take

lerna add runs a whole chain of actions redundantly validating the packages and calling the internet.

We want the β€” npm i but for packages within our monorepo!

That's what this CLI does:

deplink "detergent"

That's it. For example, symlink is created at "monorepo-root/packages/object-all-values-equal-to/node_modules/detergent" pointing to "monorepo-root/packages/detergent".

As you expect, package.json is updated, CLI's are linked properly to bin/ and devDeps can be set via a flag:

deplink "detergent" -d
deplink "detergent" --dev


Β§ Supports CLI's

If your package ("b" from the example above) is a CLI, symlinks will be put one level deeper, instead of within node_modules, for each entry in bin from package.json, a symlink will be created in node_modules/.bin/, pointing not to the root of the package "b" but straight to the file that bin entry in package.json was pointing to.

For example, lerna-clean-changelogs-cli of ours has the following bin entry in its package.json:

"bin": {
"lcc": "cli.js",
"lernacleanchangelog": "cli.js"

If you git-cloned our monorepo and wanted to link package lerna-clean-changelogs-cli to another package, two symlinks would be created, one for lcc and another for lernacleanchangelog, both pointing to the same file, cli.js.

PS. If you wonder, what happens if a package is both CLI and normal package (has both "main" and "bin" keys in package.json)? It will still work β€” both sets of symlinks will be created.


According to lerna link documentation opens in a new tab, lerna link "symlinks together all packages that are dependencies of each other". But we want just to symlink one!

By the way, it's not just me, people complain about it at Lerna's issues board here opens in a new tab, here opens in a new tab and here opens in a new tab.

Well, now those days are gone, we have a simple dependency linker at last.


Β§ The finest ingredients

Only the finest ~dependencies~ ingredients are used in this CLI:


Β§ Licence

MIT opens in a new tab

Copyright Β© 2010–2020 Roy Revelt and other contributors

Related packages:

πŸ“¦ update-versions 2.4.24
Like npm-check-updates but supports Lerna monorepos and enforces strict semver values
πŸ“¦ lerna-clean-changelogs-cli 1.2.70
CLI application to cleanse the lerna/commitizen-generated changelogs
πŸ“¦ lerna-clean-changelogs 1.3.60
Removes frivolous changelog entries from commitizen-generated changelogs