Closed rugo83 closed 2 months ago
Thanks for reporting the problem. This is fixed in Console Ninja v1.0.365
+.
I’ve updated to v1.0.356. In standard mode of NestJS, console.error works fine, but in monorepo mode, the issue still persists.
To create the monorepo mode: https://docs.nestjs.com/cli/monorepo#monorepo-mode
nest new my-project
cd my-project
nest generate app my-app
npm run start:dev
Additionally, in v1.0.356, Universal Node applications (adding the console-ninja prefix before node app.js) are not working correctly either.
Additionally, in v1.0.356, Universal Node applications (adding the console-ninja prefix before node app.js) are not working correctly either.
Thanks reporting the issue. Universal Node applications is fixed in v1.0.357.
@rugo83 - thanks for the steps to generate a nestjs mono-repo.
Console Ninja is actually reporting console.error
messages, but they are being reported against the wrong file because there's no source map support in nestjs (at least by default) when using mono-repos.
You will see the same source map issue if you were to throw new Error('boom');
in your code - you'll see it reports against /dist/main.js
instead of your source file.
Console Ninja requires source maps to report errors (and console.error
).
We found a quick way to fix this in our mono-repo, by changing the nest-cli.json
file:
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "apps/my-project/src",
"compilerOptions": {
"deleteOutDir": true,
- "webpack": true,
+ "webpack": false,
"tsConfigPath": "apps/my-project/tsconfig.app.json"
},
...
This change will force nest to generate individual files for your source code (the same as when not using a mono-repo); in this mode, source maps are emitted by default, and everything will work for you.
Alternatively, you may investigate how to generate source maps for nestjs webpack mode; this should also fix your problem.
Thank you for your help! Both my NestJS and Vite projects are working well with Console Ninja v1.0.357. However, console.error
is not showing up in Universal Node applications. Do you have any suggestions on how to resolve this issue in this version? Thanks again!
console-ninja node main.js
Please update to the latest version of Console Ninja, v1.0.358
. It should work for you.
Thank you for resolving the previous issue. I have encountered a new problem, though. As shown in the screenshot, console.error
does not support more than one parameter, and passing a regular object does not display it correctly. Could you please investigate this behavior? I appreciate your help in fixing the earlier problem and look forward to your support on this matter as well.
v1.0.359
console-ninja node main.js
Thanks for reporting your problem. By design, console.error
is handled a little differently from other console methods so that Console Ninja captures console.error
when it's output by your dependencies, not just your application code. The other console.*
methods do not work this way. Unfortunately this behavior means that what we capture is different, and limited.
We've updated Console Ninja to process console.error
calls within your application code the same way that it's processing other console.*
method calls. In your case, it will fix your problem. In cases where console.error
occurs outside of your application code (i.e. occurs in dependencies), then the previous logging behavior will take place.
Please update to Console Ninja v1.0.360
to fix your issue.
Thank you! Everything is working fine now after the update.
What happened?
Version
v1.0.355
CLI command to start your dev tool
pnpm run start:dev
Steps to reproduce (or sample repo)
nest new
Log output