lerna bootstrap not outputting full logs
See original GitHub issueCurrent 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
- Create an intentional error such as a variable that doesn’t exist in your code.
- Pin Lerna to
^5.0.0
- Run
lerna bootstrap
. You should only see a basic fail message. - Pin your Lerna version to
4.0.0
. - 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:
- Created a year ago
- Reactions:1
- Comments:7
Top 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 >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
Another piece of the puzzle on my end is that TypeScript outputs error from a run of
tsc
tostdout
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 thencat
the file to temporarily get CI output until this gets fixed. For example, I updated this:To this and finally had insight into what breaking in CI:
Lerna reports it succeeds, though, so that’s not ideal…
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 thelerna bootstrap
command) has astdout
property on it that you can calltoString()
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:
And whaddayaknow! I got the actual reason why a subsequent
lerna bootstrap
failed!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 ofstdout
upon error. Could it be that simple? 🤔