首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何在幻影脚本中使用"node_redis“?

如何在幻影脚本中使用"node_redis“?
EN

Stack Overflow用户
提问于 2017-05-18 16:01:08
回答 1查看 148关注 0票数 1

我想做一个phantomjs脚本,作为消费者进程从redis服务器上读取值。我看到存在这个用于节点的客户端(https://github.com/NodeRedis/node_redis),并且我连接、写入和读取都没有执行节点脚本时出现问题。

代码语言:javascript
代码运行次数:0
运行
复制
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执行同样的操作时,我得到了这个错误:

代码语言:javascript
代码运行次数:0
运行
复制
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一起使用?

EN

回答 1

Stack Overflow用户

发布于 2017-05-18 16:13:21

PhantomJS与node.js不兼容,您不能在其中使用此包。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44041920

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档