winstonjs / winston

A logger for just about everything.
http://github.com/winstonjs/winston
MIT License
22.83k stars 1.81k forks source link

Error: Cannot find module 'async' #303

Closed siddhion closed 11 years ago

siddhion commented 11 years ago

I am using a module called winston-google-spreadsheet https://github.com/wf9a5m75/winston-google-spreadsheet and when it calls for winston the following error gets returned

Error: Cannot find module 'async'

Here is the full error

$ node logTest.js 

module.js:340
    throw err;
          ^
Error: Cannot find module 'async'
    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/max/Desktop/logtest-project/node_modules/winston-google-spreadsheet/lib/winston-google-spreadsheet.js:6:13)
    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)

After some digging I realized the async module is located in the winston/node_modules. full path on my system is :

/home/max/Desktop/logtest-project/node_modules/winston/node_modules/async/lib/async.js

it actually exists so why is it not being found?

here is the logTest.js code which uses winston and winston-google-spreadsheet

const EMAIL = 'xxxxxxxxx@gmail.com';
const PASSWORD = 'xxxxxxxxxxxxxxxxxxx';
const FILE_ID = '0Aij5GWgC3IendHZnZWJVRlBtUmpSdHl6dmhncmh3Nmc#gid=0';

var winston = require('winston');
require('winston-google-spreadsheet').GoogleSpreadSheet;

var ssLogger = new (winston.transports.GoogleSpreadsheet)({
      'email': EMAIL,
      'password': PASSWORD,
      'fileId' : FILE_ID,
      'level' : 'info'
    });

var logger = new (winston.Logger)({
  'transports': [ssLogger],
  'exceptionHandlers': [ssLogger],
  'exitOnError': true
});

logger.log('info', 'Test Log Message', { anything: 'This is metadata' });
siddhion commented 11 years ago

I've also asked this here https://github.com/wf9a5m75/winston-google-spreadsheet/issues/1 but since the issue seems to really be about winston's async not being seen I thought this would be a better place to ask.

jcrugzz commented 11 years ago

@siddhion It will be fixed when wf9a5m75/winston-google-spreadsheet#2 is pulled in.