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 not outputting full logs

See original GitHub issue

Current Behavior

Running lerna bootstrap in Lerna 5+ has minimal logs in the console. If there is an issue in my code, It just get a generic:

The script called "bootstrap" which runs "lerna bootstrap" failed with exit code 1 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code

Expected Behavior

In Lerna 4 and below the full logs were printed to the console so you can get useful warnings and errors. For example (Edits for brevity):


[!] (plugin postcss) Error: Undefined variable.
   ╷
59 │     box-shadow: $bv-checkbox-input-focus-rin;
   │                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  stylesheets/index.scss 59:17  root stylesheet
stylesheets/index.scss
Error: Undefined variable.
   ╷
59 │     box-shadow: $bv-checkbox-input-focus-rin;
   │                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  stylesheets/index.scss 59:17  root stylesheet

...

The script called "bootstrap" which runs "lerna bootstrap" failed with exit code 1 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code

Steps to Reproduce

  1. Create an intentional error such as a variable that doesn’t exist in your code.
  2. Pin Lerna to ^5.0.0
  3. Run lerna bootstrap. You should only see a basic fail message.
  4. Pin your Lerna version to 4.0.0.
  5. Run lerna bootstrap. You should see a log with the error.

The --loglevel flag does not help. There are no other code changes to get this result. Only the Lerna version. I imagine it is something to do with the change from npm-lifecycle to @npmcli/run-script?

Failure Logs / Configuration

lerna.json

{
  "version": "independent",
  "npmClient": "npm",
  "packages": ["packages/*"],
  "command": {
    "version": {
      "allowBranch": "",
      "ignoreChanges": ["**/stories/**", "**/tests/**", "**/*.md"]
    }
  }
}

lerna-debug.log

Environment

 Environment info:

  System:
    OS: macOS 12.5.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 6.14.12 - ~/.nvm/versions/node/v14.16.1/bin/npm
  Utilities:
    Git: 2.37.3 - /usr/local/bin/git
  npmPackages:
    lerna: ^6.0.1 => 6.0.1 

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
MasterKalecommented, Nov 13, 2022

Another piece of the puzzle on my end is that TypeScript outputs error from a run of tsc to stdout when they’re reporting issues with the user’s code. See https://github.com/microsoft/TypeScript/issues/9526.

@dermyhughes This is a bit hacky, but if you’re still blocked I found out it’s possible to pipe stdout from any scripts that Lerna runs to a file and then cat the file to temporarily get CI output until this gets fixed. For example, I updated this:

rimraf dist && tsc

To this and finally had insight into what breaking in CI:

rimraf dist && tsc > output.txt; cat output.txt; rm output.txt

Lerna reports it succeeds, though, so that’s not ideal…

1reaction
MasterKalecommented, Nov 12, 2022

Interesting, I did some more digging and discovered that the err variable here in the error handler for @lerna/run-lifecycle (that eventually logs the result of the lerna bootstrap command) has a stdout property on it that you can call toString() on to get the reason the command failed!

I went into ./node_modules/@lerna/run-lifecycle/run-lifecycle.js in the root of my monorepo and added the following line to just below L156:

console.log(err.stdout.toString().trimEnd());

And whaddayaknow! I got the actual reason why a subsequent lerna bootstrap failed!

lerna ERR! lifecycle "prepublish" errored in "@simplewebauthn/server", exiting 2

> @simplewebauthn/server@6.2.2 build
> rimraf dist && tsc

src/helpers/generateChallenge.ts(25,3): error TS2304: Cannot find name 'aaa'.

It’s those last three lines that are from the call to err.stdout.toString(), and they immediately help me understand that my build is failing because I intentionally caused my code to fail while trying to figure out why Lerna won’t output anything more after an error.

So at this point I don’t know what an official fix would be - of course my modifying files in node_modules/ isn’t a solution to this problem.

I wonder if @lerna/run-lifecycle couldn’t be updated with such a simple, single-line output of stdout upon error. Could it be that simple? 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lerna: Documentation
Lerna is a fast modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
Read more >
Lerna build fails on remote - internal packages are badly ...
After hitting lerna bootstrap to install all packages dependencies, I am using lerna run build --stream on the root folder which invokes ...
Read more >
How To Manage Monorepos With Lerna - DigitalOcean
In this tutorial, you will install Lerna, create a working directory, ... bootstrap your packages, and add a dependency to all the packages....
Read more >
Question: Issue with installing dependencies for PWA kit
scripts/bootstrap.js > mobify-platform-sdks@0.10.0 lerna ... There is likely additional logging output above. npm ERR! A complete log of ...
Read more >
Untitled
The two primary commands in Lerna are `lerna bootstrap` and `lerna ... On failure, all logs are written to lerna-debug.log in the current...
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