This tutorial shows you how to add dependencies to a single package in a Lerna-managed project.
Lerna Series Overview
- Install Dependencies for a Specific Package
Install Dependency to Specific Package With Lerna
Lerna comes with an
add command to install NPM dependencies in your project’s packages. By default, lerna adds a new dependency to all managed packages.
You can scope the
add command to individual packages using the
--scope=<package-name> flag. This will install a given dependency only to
lerna add a --scope=b # add package "a" to multiple packages lerna add a --scope=b --scope=c --scope=d
Here’s a concrete example installing
@supercharge/strings as a dependency to the
lerna add @supercharge/strings --scope=@supercharge/session
That’s it! You can now use the added dependency in the related package.