ShahiM ShahiM - 3 months ago 27
Node.js Question

error when setting up loggly/winston

I am following the steps outlined here to configure loggly in my nodejs app :

npm install winston
npm install winston-loggly-bulk


and in index.js :

var winston = require('winston');
require('winston-loggly-bulk');
winston.add(winston.transports.Loggly, {
token: "8ea17e10-bfce-4f78-bc18-51ab6c61f78c",
subdomain: "qbesdeveloper",
tags: ["Winston-NodeJS"],
json:true
});


but I keep getting this error :

Error: Cannot find module 'loggly'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/user/totoapi/node_modules/winston-loggly-bulk/lib/winston-loggly.js:10:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/user/totoapi/index.js:10:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

Answer

Well, I reached out to Loggly support and they gave me a solution:

The docs say to install just winston and winston-loggly-bulk, but you need to install a third packege loggly too.

npm install winston
npm install loggly
npm install winston-loggly-bulk

I have no idea why they did not mention this in their getting started page. Anyways, I'm gonna leave this here until they update their docs.