我想做一个phantomjs脚本,作为消费者进程从redis服务器上读取值。我看到存在这个用于节点的客户端(https://github.com/NodeRedis/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一起使用?
发布于 2017-05-18 08:13:21
PhantomJS与node.js不兼容,您不能在其中使用此包。
https://stackoverflow.com/questions/44041920
复制相似问题