2017-05-18 106 views
1

我想製作一個phantomjs腳本,作爲從redis服務器讀取消費者數據的值。我發現存在這個客戶端的節點(https://github.com/NodeRedis/node_redis),我連接,寫入和讀取沒有問題執行節點腳本。如何在phantomjs腳本中使用「node_redis」?

var redis = require("redis"), 
    client = redis.createClient(); 

client.on("error", function (err) { 
    console.log("Error " + err); 
}); 

client.set("string key", "string val", redis.print); 
client.get("string key", redis.print); 

但是,當我做phantomjs同我得到這個錯誤:

ReferenceError: Can't find variable: process 

    phantomjs://platform/command.js:4 
TypeError: undefined is not a constructor (evaluating 'util.inherits(assert.AssertionError, Error)') 

    phantomjs://platform/assert.js:161 
TypeError: undefined is not a constructor (evaluating 'util.inherits(RedisError, Error)') 

    phantomjs://platform/redisError.js:17 
TypeError: undefined is not a constructor (evaluating 'util.inherits(ReplyError, RedisError)') 

    phantomjs://platform/replyError.js:16 
TypeError: undefined is not a constructor (evaluating 'util.inherits(ParserError, RedisError)') 

    phantomjs://platform/parserError.js:18 
ReferenceError: Can't find variable: Buffer 

    phantomjs://platform/parser.js:22 in bufferAlloc 
    phantomjs://platform/parser.js:8 
TypeError: undefined is not a constructor (evaluating 'util.inherits(AbortError, RedisError)') 

    phantomjs://platform/customErrors.js:43 
Error: Cannot find module 'events' 

    phantomjs://platform/bootstrap.js:299 in require 
    phantomjs://platform/bootstrap.js:263 in require 

有沒有辦法用這個包與phantomjs?

回答