[英]Node.JS object prototype may only be an Object or null with Redis
I've been trying to setup redis for my Node.JS API and I've been getting this error: 我一直在尝试为我的Node.JS API设置redis,我一直收到这个错误:
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)
Here's my code: 这是我的代码:
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 is simply a require('config') file with a config object. config只是一个带有配置对象的require('config')文件。
The problem is that superCtor.prototype
is undefined
. 问题是superCtor.prototype
undefined
。 The only valid first argument to Object.create
is either null
or a non- null
object reference; Object.create
唯一有效的第一个参数是null
或非null
对象引用; you can't use primitives (including undefined
). 你不能使用原语(包括undefined
)。
We can't say why superCtor.prototype
is undefined from the code you've quoted, but that's the problem with the Object.create
call. 我们不能说为什么从你引用的代码中未定义superCtor.prototype
,但这是Object.create
调用的问题。
I figured out the issue. 我想出了这个问题。 I had a global variable called Error
which conflicted with redis, and also some other dependencies. 我有一个名为Error
的全局变量,它与redis以及其他一些依赖项冲突。
I fixed it by simply re-naming Error
to Errors
. 我通过简单地将Error
重命名为Errors
来修复它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.