Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda