'Winston logger error logger.default.warn is not a function

I added Winston logger to my JS application and all the logs work but not the warning. I have no idea why.

The error every time I try to use .warn(warning) as

TypeError: _logger.default.warn is not a function

My logger was done in this helper utility

import { config, createLogger, format, transports } from 'winston';

const { printf, combine, timestamp, colorize } = format;

// don't show console logs in test mode
const transport =
  process.env.NODE_ENV !== 'test' ? [new transports.Console()] : [];

export default createLogger({
  levels: config.syslog.levels,
  level: 'info',
  format: combine(
    timestamp(),
    printf((info) => `[${info.timestamp}][${info.level}]: ${info.message}`),
    colorize({ all: true })
  ),
  transports: [
    ...transport,
    new transports.File({ filename: 'logs/error.log', level: 'error' }),
    new transports.File({ filename: 'logs/application.log' }),
  ],
});

and I used just under an if statement

if ( validation === 'false' ) {
    log.warn('Twilio validation is not active!'); // Here the error occur
    return next();
  }

I tried to google online but as per documentation should work so I don't know what's wrong as it is the only log not working.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source