TypeError: Class constructor TransportStream cannot be invoked without 'new'
See original GitHub issueHi,
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:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
Resolved with https://github.com/winstonjs/winston-daily-rotate-file/commit/f6e809c328432dce2af172dc8e98f998935ca39a and pushed to npm as
winston-daily-rotate-file@3.2.1
.This is because as of
winston-transport@4.0.0
is using ES6-classes and sincewinston-daily-rotate-file
requireswinston-transport
through winston we get this error.Solution should be to add
winston-transport@3.2.1
as a dependecy inpackage.json
.