Closed billdwhite closed 4 years ago
Hmmm... I haven't tried yet angular 10.x ... I will look at this now.
@darekf77: I am guessing it is related to the commit for display.ts, but that's just a guess
@billdwhite try 3.14 .... I've removed global variable.
btw don't forget:
import { Log, Level } from 'ng2-logger/browser';
@darekf77 : Yep the 3.14 fixes the issue! Thanks 👍
For me this error is back in version 4.0.7. I use the lib in a Angular 11.1 with Typescript 4.1.3 project. The problem goes away if I roll back to version 3.0.14
.
Error in browser:
Later edit:
If I add the line below at the end of the polyfills.js file, it solves the issue, but it still would be nicer to not have to do it.
(window as any).global = window;
@billdwhite Seems that I've edited my post in the same time as you added your reply :) So yeah, I can confirm that this does the trick, but still it shouldn't be needed as an extra step.
@mikeandtherest make sure that you are using 'ng2-logger/browser' not just 'ng2-logger'. Version without '/browser' is only for backend nodejs.
Yep, that was my first thought, so I can say for sure that I'm getting the error while using the proper import { Log } from 'ng2-logger/browser';
syntax (proper for browser, that is). So it must be something else that made it return in 4.0.7.
FYI, It's still not fixed in 4.0.12.
Many months later, Angular 12.2, ng2-logger 5.0.23 and the bug is still present. Is there any interest in investigating it?
@mikeandtherest I am working on ngc version for ivy/angular... probably today I will release it.
@mikeandtherest check newest version... should be ok.
@darekf77 Sorry for the late reply. And thanks for the fix, it indeed works fine now on version 8.0.20.
After updating to 3.0.13, I am getting a new error when the Logger is initialized. FYI: I'm using the latest Angular 10.1.1 and Typescript 4.0.2.
ERROR Error: Uncaught (in promise): ReferenceError: global is not defined ReferenceError: global is not defined
at msg (display.js:41) at Logger._data (logger.js:144) at Logger.data (logger.js:82) at Logger.debug (logger.ts:39) at new AppGuard (app.guard.ts:20) at Object.AppGuard_Factory [as factory] (app.guard.ts:57) at R3Injector.hydrate (core.js:11242) at R3Injector.get (core.js:11064) at NgModuleRef$1.get (core.js:24194) at getToken (router.js:2672) at resolvePromise (zone.js:1215) at resolvePromise (zone.js:1165) at zone.js:1277 at ZoneDelegate.invokeTask (zone.js:407) at Object.onInvokeTask (core.js:27419) at ZoneDelegate.invokeTask (zone.js:406) at Zone.runTask (zone.js:179) at drainMicroTaskQueue (zone.js:583)