Node.JS 对象原型在 Redis 中只能是 Object 或 null [英] Node.JS object prototype may only be an Object or null with Redis
本文介绍了Node.JS 对象原型在 Redis 中只能是 Object 或 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试为我的 Node.JS API 设置 redis我一直收到这个错误:
I've been trying to setup redis for my Node.JS API and I've been getting this error:
util.js:634
ctor.prototype = Object.create(superCtor.prototype, {
^
TypeError: Object prototype may only be an Object or null: undefined
at Function.create (native)
at Object.exports.inherits (util.js:634:27)
at Object.<anonymous> (/home/<user>/<project>/node_modules/redis/lib/parser/javascript.js:31:6)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/<user>/<project>/node_modules/redis/index.js:33:14)
这是我的代码:
console.log('Redis: ' + config.redis.host);
console.log('Redis: ' + config.redis.port);
console.log('Redis: ' + config.redis.pass);
redis = require('redis');
redisClient = redis.createClient(
config.redis.port,
config.redis.host,
{
auth_pass: config.redis.pass
}
);
config 只是一个带有配置对象的 require('config') 文件.
config is simply a require('config') file with a config object.
推荐答案
我发现了这个问题.我有一个名为 Error
的全局变量,它与 redis 以及其他一些依赖项发生冲突.
I figured out the issue. I had a global variable called Error
which conflicted with redis, and also some other dependencies.
我通过简单地将 Error
重命名为 Errors
来修复它.
I fixed it by simply re-naming Error
to Errors
.
这篇关于Node.JS 对象原型在 Redis 中只能是 Object 或 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文