How to update dependencies in sub-packages
See original GitHub issueExpected Behavior
DevDependencies can be shared amongst the root package and sub-packages. For example, it’s nice to be able to run tests in a specific package and at the root directory. This mean all packages (including root) share the same test runner. Lerna is able to hoist shared dependencies to the top (which is nice).
However, when updating shared dependencies offer no help to bump version in all packages. Of course I can use lerna exec -- npm update whatever
, but NPM will actually install the new version in each packages which can take forever.
Possible Solution
A command like lerna update
could run over every package.json
and match the version with the root.
Alternatively, in order to not rely in the root package, lerna update whatever@X.X.X
could be used to define the required version.
Steps to Reproduce (for bugs)
- Have a lot of sub-packages with outdated dependencies
- Be using
lerna bootstrap --hoist
- Wish to update all sub-packages
Context
All my sub-packages and root share AVA
, nyc
and esm
. It means I can run npm test
in the root to test everything (in CI for example) or in any sub-directory (while adding a new feature for example).
Updating these dependencies can turn into a nightmare. Running lerna exec -- npm update ava nyc esm
take way too long and moreover actually install the package when I just want to update the package.json
.
Copy-pasting the version to all package.json
and running lerna bootstrap --hoist
is viable, but as the number of sub-packages grows it becomes more and more tedious.
Your Environment
Executable | Version |
---|---|
lerna --version |
3.15.0 |
npm --version |
6.7.0 |
node --version |
11.13.0 |
OS | Version |
---|---|
Windows 10 | 1803 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:60
- Comments:19
Top GitHub Comments
That would be a nice feature. But as a workaround you could use e.g. syncpack
Example: update React from version 16.8.6 to 16.9.0.
npm outdated
Open package.json at project root and set the new versions.
Open one of the sub projectes (in ./packages) that have these dependencies and set the new versions here as well.
Save and run
npx syncpack list --peer
from project root to verify that changes are detcted.Run
npx syncpack fix-mismatches --peer
to upgrade similar dependencies in all the other subprojects.BTW: We use peerDependencies for all third party packages and dependencies for our internal packages:
I started using lerna to be able to install all node modules for all subpackages using single command. At the moment i do not use any other lerna features except
lerna bootstrap
. Mylerna.json
:my root
package.json
:my
package-a
’s package.json:my
package-b
’s package.json:i want to upgrade moment in the
package-b
. if i runyarn upgrade moment --latest
in thepackage-b
folder i got the following error:if i run
npx lerna --scope package-b exec -- "yarn upgrade moment --latest"
in the root folder i get the following error:How should i properly upgrade mode module in the lerna’s sub-package?