question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`lerna add --scope` does not update package-lock file

See original GitHub issue

When adding a new dependency to a single package using lerna add --scope {name} {dep}, the file packages/{name}/package-lock.json is not updated.

Strangely enough, when adding the same dependency to all packages (omitting --scope argument), package locks are updated correctly.

Expected Behavior

When npm’s package-lock feature is enabled, then lerna add should always update corresponding package-lock.json files, regardless of whether --scope argument was used or not.

Current Behavior

  • lerna add --scope {name} {dep} does not update packages/name/package-lock.json file.

Possible Solution

The same solution that’s already in place for lerna add with no scope?

Steps to Reproduce (for bugs)

  1. Create a simple monorepo. I created a sandbox you can use yourself:

    https://github.com/bajtos/lerna-package-locks/tree/lerna-add

  2. Run the following command:

    $ lerna add --scope app p-event
    
  3. Run git status to see what has changed:

    $ git status
    (...)
        modified:   packages/app/package.json
    
lerna.json

{
  "lerna": "3.3.0",
  "packages": [
    "packages/*"
  ],
  "version": "independent"
}

Context

I ran into this issue after we have recently enabled package-lock feature in https://github.com/strongloop/loopback-next and found out that we don’t know how correctly add new dependencies to our packages.

Your Environment

Executable Version
lerna --version 3.13.1
npm --version 6.9.0
yarn --version n/a
node --version v10.15.0
OS Version
macOS Mojave 10.14.3

Please note my global npm config in ~/.npmrc is disabling the package-lock feature. The sandbox in https://github.com/bajtos/lerna-package-locks/tree/lerna-add is explicitly enabling it by including .npmrc files in all places where it’s needed.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

10reactions
krzysztof-grzybekcommented, May 13, 2020

@bajtos Shouldn’t this issue be reopened? I just encountered this issue with yarn in lerna@3.21.0

8reactions
cathykccommented, Jan 15, 2021

Same here with lerna@3.22.1. Using npm and not yarn

Read more comments on GitHub >

github_iconTop Results From Across the Web

@loopback/monorepo - npm
Start using @loopback/monorepo in your project by running `npm i @loopback/monorepo`. There are no other projects in the npm registry using ...
Read more >
Things I wish I had known when I started JavaScript monorepo ...
We no longer need to run complicated Lerna commands to add new ... None of the packages should have a package-lock.json file present....
Read more >
Create a monorepo with Lerna | by Damian Cyrus - Medium
json and package-lock.json files. To restrict this to a number of packages, you can use the --scope option. For more information about this ......
Read more >
Linking a Package as a Lerna Package Dependency for ...
This is absolutely understandable; When I run NPM commands in the scope of @my-project/client , it is not familiar with its sibling packages, ......
Read more >
yarn add
This will also update your package.json and your yarn.lock so that other ... yarn add file:/path/to/local/folder installs a package that is on your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found