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.

[Bug]: cannot extend winston.logger

See original GitHub issue

🔎 Search Terms

class extend, extend logger

The problem

TypeError: Class extends value undefined is not a constructor or null

What version of Winston presents the issue?

v3.8.1

What version of Node are you using?

v16.16.0

If this worked in a previous version of Winston, which was it?

No response

Minimum Working Example

import * as winston from 'winston'

class LogService extends winston.Logger {
  private static instance: LogService

  constructor () {
    super({
      level: process.env.LOG_LEVEL ?? 'info',
      exitOnError: false,
      format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
    })
  }

  static getInstance = (): LogService => {
    if (LogService.instance == null) { LogService.instance = new LogService() }
    return LogService.instance
  }
}

export default LogService

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jianzhou520commented, Aug 6, 2022

same issue

0reactions
ludgereycommented, Sep 8, 2022

Having a similar issue with Transport. Is this related?

class WinstonEventEmitterTransport extends Transport {
                                           ^
TypeError: Class extends value undefined is not a constructor or null

Not sure if I’ve understood correctly but I am able to extend from Transport class using the 'winston-transport' module.

I got my specific problem fixed by by setting "esModuleInterop": true" in tsconfig.json. Sorry for the late update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to inject winston's logger instance with NestJS
I'm trying to integrate Winston into NestJS, but so far, I'm unable to inject a logger instance (to actually log anything) into any ......
Read more >
Node.js Logging with Winston - Reflectoring
Logging is used to provide accurate context about what occurs in our application, it is the documentation of all events that happen within ......
Read more >
Node Logging Basics - The Ultimate Guide To Logging - Loggly
Winston can transport logs to an external location or query them when analyzing a problem. Vendor Libraries. Several log management vendors also supply...
Read more >
Best Practices for Node.js Error-handling - Toptal
With that in mind, you should have no problem distinguishing between these ... It is a good decision to employ a customizable logger...
Read more >
How to use PM2 for monitoring production Node JS applications
In the end, we'll have a working Node JS express app with logging and ... What problem does Winston solve that we can't...
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