我开始使用kue作业队列,如果我的制作人工作
,我正在尝试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);
但是我收到错误错误:找不到模块'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)
答案 0 :(得分:0)
您需要运行
npm install kue
您还可以通过--save
切换到该命令,将依赖项保存在package.config
文件中