我正在开始 kue 工作队列,我正在尝试我的制片人是否工作
生产者.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);
但是我收到错误错误:找不到模块'kue'。但是我已经在全球范围内安装了 kue。
这是错误
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)