Skip to content

How to update dependencies in sub-packages #2142

@GMartigny

Description

@GMartigny

Expected 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 [email protected] could be used to define the required version.

Steps to Reproduce (for bugs)

  1. Have a lot of sub-packages with outdated dependencies
  2. Be using lerna bootstrap --hoist
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: package managementIssues with the bootstrap/add/link commands that relate to package management

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions