winston-cloudwatch icon indicating copy to clipboard operation
winston-cloudwatch copied to clipboard

Import/Require correct way to do it

Open angelmartinez-wz opened this issue 7 years ago • 7 comments
trafficstars

If winston-cloudwatch is a library, why the README says in Usage WinstonCloudWatch = require('../index');

angelmartinez-wz avatar Sep 20 '18 17:09 angelmartinez-wz

Because I did not spot the issue, that particular line in the README is 3 years old and has been taken from the examples.

Thanks, corrected!

lazywithclass avatar Sep 24 '18 13:09 lazywithclass

So I'm using 1.13.1, because I prefer Winston 2.x. However, I can't import or require at all!

import WinstonCloudWatch from 'winston-cloudwatch';
console.log(WinstonCloudWatch);

prints {}.

import * as WinstonCloudWatch from 'winston-cloudwatch';
console.log(WinstonCloudWatch);

prints { default: {}, [Symbol(__esModule)]: true }.

Similarly with const WinstonCloudWatch = require('winston-cloudwatch');.

Seems like nothing is exported... Any ideas?

cpury avatar Nov 29 '18 09:11 cpury

Are you importing first winston?

angelmartinez-wz avatar Nov 29 '18 16:11 angelmartinez-wz

Yes! I'm using Meteor, but that should not make any difference.

cpury avatar Nov 29 '18 16:11 cpury

Hello @angelmartinez-wz, which Node.js version are you using?

I think that your issue is related to the fact that you're importing winston-cloudwatch. It's been quite a while since I wrote a Node.js program, but I don't think I've written this library with ES6 modules in mind, I'm simply using module.exports. If you try to require it the old way it should work.

Sorry if this sounds strange, but I've been disconnected from the Node.js scene for quite a while now :D

lazywithclass avatar Dec 04 '18 19:12 lazywithclass

@lazywithclass I assume you mean me :) thanks for your response, but as mentioned in my comment, I also tried requireing it with the same result

cpury avatar Dec 04 '18 21:12 cpury

Yes I meant you ^^"

I did not notice you mentioned require too, sorry. Could you please paste here the minimum example that does not work when you use require, along with Node.js version, etc?

Thanks!

lazywithclass avatar Dec 06 '18 14:12 lazywithclass