lerna --version incorrectly updates package-lock.json generated with npm@7
See original GitHub issueExpected Behavior
Package version should be correctly updated in package-lock.json version 2 with lerna --version
command.
Current Behavior
When package-lock.json in version 2 is used (generated by npm@7) then lerna --version
command updates only the first (root) version information in the package-lock.json. The information in the packages
section of package-lock.json is left with an old version.
{
"name": "@space/types",
"version": "1.0.13",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@space/types",
"version": "1.0.11",
"dependencies": {
"@space/constants": "file:../constants",
"fp-ts": "^2.9.5",
"io-ts": "^2.2.14",
"joi": "^17.4.0"
}
},
(...)
Steps to Reproduce (for bugs)
- Install and use npm@7
- Create a lerna monorepo with “version”: “independent”
- Add a package, publish it to have an initial version published
- Make some changes in the package, commit, push
- Run
lerna --version
to tag a new version - Review pushed changes in package-lock.json
lerna.json
{
"packages": [
"packages/*"
],
"version": "independent",
"command": {
"publish": {
"ignoreChanges": [
"*.md"
],
"registry": "<redacted>"
}
}
}
Your Environment
Executable | Version |
---|---|
lerna --version |
3.22.1 |
npm --version |
7.6.0 |
node --version |
14.15.0 |
OS | Version |
---|---|
macOS Catalina | 10.15.7 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:11
Top Results From Across the Web
npm WARN old lockfile The package-lock.json file was ...
Commit the updated version of package-lock.json to the repo/Docker ... And npm@7 which is the latest release generates package-lock@v2 .
Read more >npm-check-updates
npm -check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions.
Read more >Things I wish I had known when I started JavaScript monorepo ...
I think the biggest problem with Lerna lies in it's documentation. ... monorepo - package.json (root package.json) - pacakge-lock.json (root ...
Read more >Solving conflicts in package-lock.json - TkDodo's blog
npm will automatically resolve any conflicts for you and write a merged package lock that includes all the dependencies from both branches in...
Read more >JavaScript package managers compared: npm, Yarn, or pnpm?
Install or update Yarn Classic to the latest 1.x version ... With $ npm install , or the shorter $ npm i ,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@k-koehler I’m using my fix from this PR https://github.com/lerna/lerna/pull/2914 with https://github.com/ds300/patch-package
I can reproduce the issue and I understand what’s happening, but I have no solution.
It comes from an inconsistent installation of npm. The version you have in your path differs from the one actually used by lerna in the packages.
I use
npm@7.6.3
withnode@14.16.0
. I installed thenode@14
package with Homebrew which initially comes withnpm@6.14.11
but updated it withnpm i -g npm --force
. When I use npm from my shell:But lerna doesn’t use the same binary for
npm
, it uses the one intially installed withnode@14
This is confirmed by test
which npm
from the shell:And from
lerna exec
:Using
lerna info
, this is not detected:I didn’t find what
$PATH
lerna exec
uses, nor how to configure it to use the same one as the current shell.