Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
TypeError: Cannot destructure property 'combine' of 'winston_1.default.format' as it is undefined

The following error occurred while using winton in Node.js, how can we solve it?

my winston version is 3.3.3 and winston-daily-rorate-file version is 4.5.0

I've tried npm i winston@next --save, but there's still an error.

** this is my Error ** C:\workspace\cms\src_common\library\logger.library.ts:34 const { combine, timestamp, printf, prettyPrint } = winston.format; ^ TypeError: Cannot destructure property 'combine' of 'winston_1.default.format' as it is undefined. at Object. (C:\workspace\cms\src_common\library\logger.library.ts:34:9) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:93:18) at Object. (C:\workspace\cms\src_common\core\service.core.ts:3:1) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) ** this is my code **

import { ConsoleLogger, Injectable, Logger } from '@nestjs/common';
import { format } from 'prettier';
import winston from 'winston';
import winstonDaily from 'winston-daily-rotate-file';

export class LoggerLibrary extends ConsoleLogger {
    log(message: string) {
        /* your implementation */
        logger.info(message);
        super.log(message);
    }
    error(message: string, trace: any) {
        /* your implementation */
        logger.error(message, trace);
        super.error(message);
    }
    warn(message: string) {
        /* your implementation */
        logger.warn(message);
        super.warn(message);
    }
    debug(message: string) {
        /* your implementation */
        logger.debug(message);
        super.debug(message);
    }
    verbose(message: string) {
        /* your implementation */
        logger.verbose(message);
        super.verbose(message);
    }
}

const { combine, timestamp, printf, prettyPrint } = winston.format;
const logFormat = printf((info) => {
    return `${info.timestamp} ${info.level}: ${info.message}`;
});
console.log(winston)
const logger = winston.createLogger({
    format: combine(
        timestamp({
            format: 'YYYY-MM-DD HH:mm:ss',
        }),
        logFormat,
        prettyPrint(),
    ),
    transports: [
        new winstonDaily({
            level: 'error',
            datePattern: 'YYYY-MM-DD',
            dirname: 'logs/error', // error.log 파일은 /logs/error 하위에 저장
            filename: `%DATE%.error.log`,
            maxFiles: 30,
            zippedArchive: true,
        }),
    ],
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!