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.

TypeError: Class constructor TransportStream cannot be invoked without 'new'

See original GitHub issue

Hi,

I’ve updated my npm dependencies this morning and my loggers can’t start anymore with winston-daily-rotate-file@3.2.0 and winston@3.0.0-rc6.

I have this error

TypeError: Class constructor TransportStream cannot be invoked without 'new'
at new DailyRotateFile (/home/workspace/node_modules/winston-daily-rotate-file/daily-rotate-file.js:32:15)

When i set up my loggers

const logger = winston.createLogger({
  level: LOG_LEVEL,
  levels: logLevels.levels,
  format: fileFormat,
  transports: [
    new DailyRotateFile({ filename: path.join(LOGS_DIR, 'error.log'), datePattern: 'YYYY-MM-DD', level: 'error', handleExceptions: true, maxSize: '20m', maxFiles: '2d', zippedArchive: true, datePattern: 'YYYY-MM-DD-HH'}),
    new DailyRotateFile({ filename: path.join(LOGS_DIR, 'silly.log'), datePattern: 'YYYY-MM-DD', level: 'silly', maxSize: '20m', maxFiles: '2d', zippedArchive: true, datePattern: 'YYYY-MM-DD-HH' }),
    new DailyRotateFile({ filename: path.join(LOGS_DIR, 'combined.log'), datePattern: 'YYYY-MM-DD', level: LOG_LEVEL, maxSize: '20m', maxFiles: '2d', zippedArchive: true, datePattern: 'YYYY-MM-DD-HH' })
  ]
});

winston@3.0.0-rc6 needs winston-transport@^4.0.0 and the error occurs in winston-daily-rotate-file when calling

Transport.call(this, options);

Looks like there is an issue with winston-transport. Maybe i’m not setting up thing in the right way, but it was working so far. My previous version of winston was @next, so i can’t tell what was my real version of winston. Reproduced on two different machines with Node version 8.9.4 or 9.5.0

Can you reproduce the issue ?

Regards.


Edit: searching in my git history and according to publish dates, i think my working version was winston@3.0.0-rc5 with winston-transport@^3.1.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mattberthercommented, May 30, 2018

Resolved with https://github.com/winstonjs/winston-daily-rotate-file/commit/f6e809c328432dce2af172dc8e98f998935ca39a and pushed to npm as winston-daily-rotate-file@3.2.1.

1reaction
ChrisAldersoncommented, May 30, 2018

This is because as of winston-transport@4.0.0 is using ES6-classes and since winston-daily-rotate-file requires winston-transport through winston we get this error.

Solution should be to add winston-transport@3.2.1 as a dependecy in package.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class constructor cannot be invoked without 'new' in JS/TS
The "TypeError: Class constructor cannot be invoked without 'new'" error occurs for 2 reasons: Trying to instantiate a class without using the new...
Read more >
Javascript ES6 TypeError: Class constructor Client cannot be ...
When I try to execute nodemon command I always see this error TypeError: Class constructor Client cannot be invoked without 'new'.
Read more >
Javascript ES6 TypeError Class constructor Client cannot be ...
When I try to execute nodemon command I always see this error TypeError: Class constructor Client cannot be invoked without 'new'.
Read more >
Class constructor NodeEnvironment cannot be invoked ...
Determining test suites to run…Setup Mongo Connection FAIL test/db-connection.test.js ○ Test suite failed to run TypeError: Class ...
Read more >
Class constructor Class cannot be invoked without 'new'
I'm getting the following error in the console of the browser, when trying to access my route “login”: Uncaught (in promise) TypeError: ...
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