Skip to content

exports.default causing TypeError: HumioTransport is not a constructor #6

@nbgslv

Description

@nbgslv

Using ver 1.0.6, I received a "TypeError: HumioTransport is not a constructor" error.
My use case:

const winston = require('winston');
const HumioTransport = require('humio-winston');
const config = require('../config');

const transports = [];
transports.push(
  new winston.transports.Console({
    level: config.logs.level,
    format: winston.format.combine(
      winston.format.combine(
        winston.format.timestamp(),
        winston.format.errors({ stack: true }),
        winston.format.splat(),
        winston.format.cli(),
        winston.format.colorize({ level: true })
      )
    ),
  })
);
transports.push(
  new winston.transports.File({
    filename: `./logs/log_file.log`,
    format: winston.format.combine(winston.format.timestamp(), winston.format.splat()),
  })
);
transports.push(
  new HumioTransport({
    ingestToken: proccess.env.humioToken,
    callback: err => {
      if (err) console.log(err);
    },
  })
);

I think the problem is in the way the package is being compiled. In my node_modules/humio-winston the humio-winston.js file ended with exports.default = HumioTransport. I changed it to module.exports = HumioTransport and everything worked fine.

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
...
class HumioTransport extends winston_transport_1.default {
...
exports.default = HumioTransport; module.exports = HumioTransport;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions