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 version does not take npmClientArgs into account

See original GitHub issue

Current Behavior

When i run lerna version with npmClientArgs set to ["--legacy-peer-deps"], it crashes while doing npm install --package-lock-only --ignore-scripts because of unmet peer dependencies. I had a look at the sources and can see npmClientArgs not being used there.

Error output:

lerna ERR! Error: Command failed with exit code 1: npm install --package-lock-only --ignore-scripts
lerna ERR! npm ERR! code ERESOLVE
lerna ERR! npm ERR! ERESOLVE could not resolve
lerna ERR! npm ERR!
lerna ERR! npm ERR! While resolving: eslint-plugin-react-app@6.2.2
lerna ERR! npm ERR! Found: eslint@8.25.0
lerna ERR! npm ERR! node_modules/eslint
lerna ERR! npm ERR!   dev eslint@"^8.11.0" from the root project
lerna ERR! npm ERR!   peer eslint@"^7.5.0 || ^8.0.0" from @babel/eslint-parser@7.19.1
lerna ERR! npm ERR!   node_modules/@babel/eslint-parser
lerna ERR! npm ERR!     @babel/eslint-parser@"^7.16.3" from eslint-config-react-app@7.0.1
lerna ERR! npm ERR!     node_modules/eslint-config-react-app
lerna ERR! npm ERR!       dev eslint-config-react-app@"^7.0.0" from the root project
lerna ERR! npm ERR!   22 more (@typescript-eslint/eslint-plugin, ...)
lerna ERR! npm ERR!
lerna ERR! npm ERR! Could not resolve dependency:
lerna ERR! npm ERR! peer eslint@"6.x" from eslint-plugin-react-app@6.2.2
lerna ERR! npm ERR! node_modules/eslint-plugin-react-app
lerna ERR! npm ERR!   dev eslint-plugin-react-app@"^6.2.2" from the root project
lerna ERR! npm ERR!
lerna ERR! npm ERR! Conflicting peer dependency: eslint@6.8.0
lerna ERR! npm ERR! node_modules/eslint
lerna ERR! npm ERR!   peer eslint@"6.x" from eslint-plugin-react-app@6.2.2
lerna ERR! npm ERR!   node_modules/eslint-plugin-react-app
lerna ERR! npm ERR!     dev eslint-plugin-react-app@"^6.2.2" from the root project

Expected Behavior

npmClientArgs is taken into account everywhere when calling npm, but especially here in the version command. Hence the call should be: npm install --package-lock-only --ignore-scripts --legacy-peer-deps.

Steps to Reproduce

https://github.com/alex3683/lerna-npm-args-bug

See README.md for what to do.

Failure Logs / Configuration

lerna.json

{
  "packages": [
    "applications/*",
    "libraries/*",
    "templates/*"
  ],
  "version": "3.11.3",
  "npmClient": "npm",
  "useWorkspaces": true,
  "npmClientArgs": [
    "--legacy-peer-deps"
  ]
}

lerna-debug.log

0 silly argv {
0 silly argv   _: [ 'version' ],
0 silly argv   'git-tag-version': false,
0 silly argv   gitTagVersion: false,
0 silly argv   push: false,
0 silly argv   exact: true,
0 silly argv   'force-publish': true,
0 silly argv   forcePublish: true,
0 silly argv   yes: true,
0 silly argv   y: true,
0 silly argv   lernaVersion: '6.0.1',
0 silly argv   '$0': 'node_modules\\lerna\\cli.js',
0 silly argv   bump: 'v3.11.3'
0 silly argv }
1 notice cli v6.0.1
2 verbose rootPath C:\projects\...\frontends
3 info current version 3.11.3
4 notice FYI git repository validation has been skipped, please ensure your version bumps are correct
5 silly hasTags
6 verbose hasTags true
7 silly git-describe.sync "v3.10.0-148-g330cd2152-dirty" => {"lastTagName":"v3.10.0","lastVersion":"v3.10.0","refCount":"148","sha":"330cd2152","isDirty":true}
8 warn force-publish all packages
9 info Assuming all packages changed
10 verbose updated admin
11 verbose updated calendar
12 verbose updated catering
13 verbose updated desk-sharing
14 verbose updated desk-sign
15 verbose updated device-finder
16 verbose updated device-lobby
17 verbose updated service-terminal
18 verbose updated setup
19 verbose updated device-sdk
20 verbose updated frontend-shared-library
21 verbose updated react-boilerplate
22 warn version Skipping working tree validation, proceed at your own risk
23 info auto-confirmed
24 info execute Skipping git tag/commit
25 info execute Skipping git push
26 info execute Skipping releases
27 silly lifecycle No script for "preversion" in "root", continuing
28 silly lifecycle No script for "preversion" in "frontend-shared-library", continuing
29 verbose version frontend-shared-library has no lockfile. Skipping lockfile update.
30 silly lifecycle No script for "version" in "frontend-shared-library", continuing
31 silly lifecycle No script for "preversion" in "calendar", continuing
32 silly lifecycle No script for "preversion" in "catering", continuing
33 silly lifecycle No script for "preversion" in "desk-sharing", continuing
34 silly lifecycle No script for "preversion" in "device-finder", continuing
35 silly lifecycle No script for "preversion" in "setup", continuing
36 silly lifecycle No script for "preversion" in "device-sdk", continuing
37 silly lifecycle No script for "preversion" in "react-boilerplate", continuing
38 verbose version calendar has no lockfile. Skipping lockfile update.
39 verbose version catering has no lockfile. Skipping lockfile update.
40 verbose version device-finder has no lockfile. Skipping lockfile update.
41 verbose version desk-sharing has no lockfile. Skipping lockfile update.
42 verbose version device-sdk has no lockfile. Skipping lockfile update.
43 verbose version setup has no lockfile. Skipping lockfile update.
44 verbose version react-boilerplate has no lockfile. Skipping lockfile update.
45 silly lifecycle No script for "version" in "device-finder", continuing
46 silly lifecycle No script for "version" in "calendar", continuing
47 silly lifecycle No script for "version" in "catering", continuing
48 silly lifecycle No script for "version" in "desk-sharing", continuing
49 silly lifecycle No script for "version" in "device-sdk", continuing
50 silly lifecycle No script for "preversion" in "admin", continuing
51 silly lifecycle No script for "preversion" in "desk-sign", continuing
52 silly lifecycle No script for "preversion" in "device-lobby", continuing
53 silly lifecycle No script for "preversion" in "service-terminal", continuing
54 silly lifecycle No script for "version" in "react-boilerplate", continuing
55 silly lifecycle No script for "version" in "setup", continuing
56 verbose version admin has no lockfile. Skipping lockfile update.
57 verbose version service-terminal has no lockfile. Skipping lockfile update.
58 verbose version device-lobby has no lockfile. Skipping lockfile update.
59 verbose version desk-sign has no lockfile. Skipping lockfile update.
60 silly lifecycle No script for "version" in "service-terminal", continuing
61 silly lifecycle No script for "version" in "desk-sign", continuing
62 silly lifecycle No script for "version" in "admin", continuing
63 silly lifecycle No script for "version" in "device-lobby", continuing
64 verbose version Updating root package-lock.json
65 error Error: Command failed with exit code 1: npm install --package-lock-only --ignore-scripts
65 error npm ERR! code ERESOLVE
65 error npm ERR! ERESOLVE could not resolve
65 error npm ERR!
65 error npm ERR! While resolving: eslint-plugin-react-app@6.2.2
65 error npm ERR! Found: eslint@8.25.0
65 error npm ERR! node_modules/eslint
65 error npm ERR!   dev eslint@"^8.11.0" from the root project
65 error npm ERR!   peer eslint@"^7.5.0 || ^8.0.0" from @babel/eslint-parser@7.19.1
65 error npm ERR!   node_modules/@babel/eslint-parser
65 error npm ERR!     @babel/eslint-parser@"^7.16.3" from eslint-config-react-app@7.0.1
65 error npm ERR!     node_modules/eslint-config-react-app
65 error npm ERR!       dev eslint-config-react-app@"^7.0.0" from the root project
65 error npm ERR!   22 more (@typescript-eslint/eslint-plugin, ...)
65 error npm ERR!
65 error npm ERR! Could not resolve dependency:
65 error npm ERR! peer eslint@"6.x" from eslint-plugin-react-app@6.2.2
65 error npm ERR! node_modules/eslint-plugin-react-app
65 error npm ERR!   dev eslint-plugin-react-app@"^6.2.2" from the root project
65 error npm ERR!
65 error npm ERR! Conflicting peer dependency: eslint@6.8.0
65 error npm ERR! node_modules/eslint
65 error npm ERR!   peer eslint@"6.x" from eslint-plugin-react-app@6.2.2
65 error npm ERR!   node_modules/eslint-plugin-react-app
65 error npm ERR!     dev eslint-plugin-react-app@"^6.2.2" from the root project
65 error npm ERR!
65 error npm ERR! Fix the upstream dependency conflict, or retry
65 error npm ERR! this command with --force, or --legacy-peer-deps
65 error npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
65 error npm ERR!
65 error npm ERR! See C:\Users\wilden\AppData\Local\npm-cache\eresolve-report.txt for a full report.
65 error
65 error npm ERR! A complete log of this run can be found in:
65 error npm ERR!     C:\Users\wilden\AppData\Local\npm-cache\_logs\2022-10-21T11_23_36_901Z-debug-0.log
65 error     at makeError (C:\projects\...\frontends\node_modules\execa\lib\error.js:60:11)
65 error     at handlePromise (C:\projects\...\frontends\node_modules\execa\index.js:118:26)

Environment

lerna notice cli v6.0.1

 Environment info:

  System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz
  Binaries:
    Node: 16.18.0 - ~\.nvm\versions\node\v16.18.0\bin\node.EXE
    Yarn: 1.22.19 - ~\.yarn\bin\yarn.CMD
    npm: 8.19.2 - ~\.nvm\versions\node\v16.18.0\bin\npm.CMD
  Utilities:
    Git: 2.36.0. - /mingw64/bin/git

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

3reactions
alex3683commented, Nov 10, 2022

@jeeten-parmar No real solution, just a dirty workaround to be able to use it when needed. In my case I just added hardcoded in node_modules\@lerna\version\index.js line 634 the parameter I was needing like this: .exec("npm", ["install", "--package-lock-only", "--ignore-scripts", "--legacy-peer-deps"], this.execOpts)

So the complete block around there then looks like this:

if (this.options.npmClient === "npm" || !this.options.npmClient) {
      const lockfilePath = path.join(this.project.rootPath, "package-lock.json");
      if (fs.existsSync(lockfilePath)) {
        chain = chain.then(() => {
          this.logger.verbose("version", "Updating root package-lock.json");
          return childProcess
            .exec("npm", ["install", "--package-lock-only", "--ignore-scripts", "--legacy-peer-deps"], this.execOpts)
            .then(() => {
              changedFiles.add(lockfilePath);
            });
        });
      }
    }

I assume that the npmClientArgs should just be respected and included here, but had no time to investigate myself yet.

0reactions
ghiscodingcommented, Dec 28, 2022

I guess this issue can be closed since v6.3.0 has added the npmClientArgs which is supposed to fix this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

lerna | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
FAQ | Lerna
Sometimes, lerna publish does not work. Your network may have had a hiccup, you may have not been logged on to npm, etc....
Read more >
Lerna NPM | npm.io
json package versions and dependency versions, but it will not actually publish the packages to npm. This flag can be combined with --skip-git...
Read more >
No BS monorepo - Part 1 - DEV Community ‍ ‍
Part 1 (this one) - where I build the monorepo using Yarn workspaces and Lerna to the point I can bump a new...
Read more >
A guide through The Wild Wild West of setting up a mono repo ...
version.ignoreChanges : an array of globs that won't be included in lerna changed/publish . Use this to prevent publishing a new version unnecessarily ......
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