0

I am getting started on kue job queue an i am trying out if my producer works

producer.js

var kue = require('kue')
, redis = require('redis');

  kue.redis.createClient = function() {
    var client = redis.createClient(6379, '127.0.0.1');
    client.auth('');
    return client;
  };
  var jobs = kue.createQueue();

var sequence = 0;

setInterval(
  function() {
  sequence += 1;
  (function(sequence) {
  var job = jobs.create('email',{
  title: 'Hello #' + sequence
  ,to: 'whatemail@gmail.com'
  ,body: 'Hello from node!'
  }).save();

  job.on('complete', function(){
  console.log('job ' + sequence + ' completed!')
  });

  job.on('failed', function() {
  console.log('job ' + sequence + 'failed!')
  });
  })(sequence);
  }
  ,1000);

I however get the error Error: Cannot find module 'kue'.I however have installed kue globally.

This is the error

C:\kueapps>node producer.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'kue'
    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> (C:\kueapps\producer.js:1:73)
    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 Function.Module.runMain (module.js:497:10)
Gandalf
  • 1
  • 29
  • 94
  • 165
  • 2
    Try installing it locally. On Unix, an alternative would be to set the `NODE_PATH` variable so it includes the global `node_modules` directory, but I don't know if that'll work on Windows. – robertklep Apr 08 '13 at 08:25
  • Thanks.I have installed it locally and it works. – Gandalf Apr 08 '13 at 09:46

1 Answers1

0

You'll need to run

npm install kue

You could also ad the --save switch to the command, to save the dependency in your package.config file

Alex
  • 37,502
  • 51
  • 204
  • 332