winstonjs/winston-loggly

Winston transport gives "Invalid transport" error on a require

RomanADavis opened this issue · 5 comments

I didn't write any of the code that this error points to and, as far as I know, neither did my team. This error shows up whenever I try to start our app. Something is weird with the way npm install is handling winston-transport. Any help is welcome.

src\private\node_modules\winston-transport\legacy.js:18
    throw new Error('Invalid transport, must be an object with a log method.');
    ^

Error: Invalid transport, must be an object with a log method.
    at new LegacyTransportStream (C:\Users\me\eclipse-workspace\product\src\private\node_modules\winston-transport\legacy.js:18:11)
    at DerivedLogger.add (C:\Users\me\eclipse-workspace\product\src\private\node_modules\winston\lib\winston\logger.js:245:9)
    at Object.winston.(anonymous function).args [as add] (C:\Users\me\eclipse-workspace\product\src\private\node_modules\winston\lib\winston.js:101:55)
    at Object.<anonymous> (C:\Users\me\eclipse-workspace\product\src\private\utils\winstonLogger.js:9:9)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)

Seem to have fixed it by changing winston from "*" to "2.*" Good luck with the new version.

what do you mean change it from "" to "2.", where can i do this change?

"winston": "*" replace to "winston": "2.*" in packeag.json file.

I didn't write any of the code that this error points to and, as far as I know, neither did my team. This error shows up whenever I try to start our app. Something is weird with the way npm install is handling winston-transport. Any help is welcome.

src\private\node_modules\winston-transport\legacy.js:18
    throw new Error('Invalid transport, must be an object with a log method.');
    ^

Error: Invalid transport, must be an object with a log method.
    at new LegacyTransportStream (C:\Users\me\eclipse-workspace\product\src\private\node_modules\winston-transport\legacy.js:18:11)
    at DerivedLogger.add (C:\Users\me\eclipse-workspace\product\src\private\node_modules\winston\lib\winston\logger.js:245:9)
    at Object.winston.(anonymous function).args [as add] (C:\Users\me\eclipse-workspace\product\src\private\node_modules\winston\lib\winston.js:101:55)
    at Object.<anonymous> (C:\Users\me\eclipse-workspace\product\src\private\utils\winstonLogger.js:9:9)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)

I'm also getting the same error for the below line that I've written in my project,
winston.add(winston.transports.File, {filename: 'logfile.log'});
Note: The version of Winston I'm using is "3.3.3", still the same error

If you also have below statement in your project then replace this statement:
winston.add(winston.transports.File, { filename: 'logfile.log' });

to this:
winston.add(new winston.transports.File({ filename: 'logfile.log' }));

And the error is gone! Cheers!