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)
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.
The problem is that superCtor.prototype
is undefined
. The only valid first argument to Object.create
is either null
or a non-null
object reference; you can't use primitives (including 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.
I figured out the issue. I had a global variable called Error
which conflicted with redis, and also some other dependencies.
I fixed it by simply re-naming Error
to Errors
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With