-
yarn <package>Do not install dependencies as
yarn <package dependency>. We uselernaand the way it works for the project is by installingdependenciesto thepackagesorserversthat 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.jsonshould have all thedevDependenciesof the project whilepackages&serversfile references should be underdependenciessection as shown here.Sometimes we may need to
pina 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 inserversorpackagesotherwise 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
packagesorservers'spackage.jsonfile directly to add adependenciesand then runyarn lernato install them. This is a easy way to install a known version by adding to the targetpacakage.jsonfile.