-
yarn <package>
Do not install dependencies as
yarn <package dependency>
. We uselerna
and the way it works for the project is by installingdependencies
to thepackages
orservers
that requires it. In most cases, you can just add the package to frontend or backend by running followingto add to the frontend server so browser gets it
lerna add --scope=*fronted-server <package>
to add to the backend server for nodejs to use it
lerna add --scope=*backend-server <package>
If a dependency is just needed by one package, you can add to that package's package.json file
lerna add --scope=<package name> <package>
Ideally, root
package.json
should have all thedevDependencies
of the project whilepackages
&servers
file references should be underdependencies
section as shown here.Sometimes we may need to
pin
a package as other dependencies can bring some older versions of the package we want to add. In that case we can pin the required package version by adding to thepacakge.json
. But make sure you don't have different version of the package inservers
orpackages
otherwise a duplciate package will be added to itsnodemodules
.
-
Each package version should be uniform across the repository
Before adding a
<package dependency>
, see if the package of different version exist. If it exist then update that version to the required version. -
You can edit one of the
packages
orservers
'spackage.json
file directly to add adependencies
and then runyarn lerna
to install them. This is a easy way to install a known version by adding to the targetpacakage.json
file.