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 bootstrap modifies package-lock.json files

See original GitHub issue

Our project have several packages: A B C depends on A & B D depends on A, B & C

all packages have package-lock.json file.

When running lerna --bootstrap

Expected Behavior

symbolic links should be created. package-lock.json should not be modified (only when running lerna publish, package-lock.json should be modified)

Current Behavior

symbolic links are created. package-lock.json files are modified, removing references of all local packages.

Workaround: running lerna exec --concurrency 1 git checkout -- package-lock.json right after lerna bootstrap to correct package-lock.json files

Environment info:

System: OS: Windows 10 10.0.17134 CPU: (8) x64 Intel® Core™ i7-8650U CPU @ 1.90GHz Binaries: Node: 12.15.0 - C:\Program Files\nodejs\node.EXE npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD Utilities: Git: 2.25.0. npmPackages: lerna: 3.20.2 => 3.20.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:13

github_iconTop GitHub Comments

13reactions
raijinsetsucommented, Apr 3, 2020

lerna bootstrap is just calling npm install under the hood after removing local packages from the package.json. So, expect your package-lock.json file to change per npm’s algorithm.

Use lerna bootstrap --ci to prevent the package-lock.json changes.

8reactions
zgriesingercommented, Mar 4, 2020

We have encountered a similar “issue”.

It seems the lerna bootstrap command is functioning as intended. In our case we have this scenario:

  • Using npm
  • Using lerna bootstrap --hoist
  • Managing private packages that are not pushed to remote
  • 1 package-lock file at root (Because dependencies are hoisted)

When cloning the repo, we were having users run npm install. The issue with this, is that it will completely rewrite the root package-lock.json file to only have the dependencies specified at the root. This removes the entries written to the lock file with lerna bootstrap --hoist. Then, when a user runs lerna bootstrap --hoist they get every single dependency with a ^ in the version updated.

Once we started omitting the npm install step and requiring a pure clone to use npx lerna bootstrap --hoist to pull down dependencies, our package-lock.json file started to look like we would expect, with only new additions being new added dependencies.

However, this is a little bit unorthodox. Having a repository using npm but requiring users to not run npm install is weird for new users. We have added this to prevent someone from inadvertently running npm install:

 "preinstall": "echo 'Please use `npx lerna bootstrap` to install dependencies' && exit 1",

Using yarn as a package manager somewhat gets around this, because the bootstrap step and the initial install step uses the same (yarn) binary. We haven’t switched to yarn because it doesn’t provide an easy way to run a scoped bootstrap when dependencies are private and not published to any registry.

I’d be interested to know if there’s any way to maintain the ability to to a pure npm install without rewriting the root package-lock and thus causing lerna bootstrap --hoist to upgrade all ^ dependencies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lerna not generating package-lock.json for every package
My expectation was that for every package.json file corresponding package-lock.json should be generated but that is not the case. Furthermore, ...
Read more >
package-lock.json - infra/infra/crdx/chopsui-npm - Git at Google
"resolved": "https://registry.npmjs.org/@lerna/batch-packages/-/batch-packages ... ://registry.npmjs.org/@lerna/write-log-file/-/write-log-file-3.13.0.tgz",.
Read more >
@lerna/bootstrap - npm
Bootstrap the packages in the current Lerna repo. Installs all of their dependencies and links any cross-dependencies.
Read more >
Starting with Monorepos using Lerna - Joel H. Gomez Paredes
To continue execute the next command: lerna bootstrap --hoist. The result of this command creates a new file package-lock.json and a node_modules in...
Read more >
How to maintain a monorepo using Lerna and NPM 7
First issue I've encountered is that whenever running lerna bootstrap , it updated package-lock.json files to use tabs instead of spaces.
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