stockholmux/node_redis-rejson

TypeError: redis.addCommand is not a function

Muntzer opened this issue · 5 comments

Hi,

I get this errror:

TypeError: redis.addCommand is not a function
at D:\RedisPoc\node_modules\redis-rejson\index.js:5:11
at Array.forEach ()
at addReJSONModule (D:\RedisPoc\node_modules\redis-rejson\index.js:4:8)
at Object. (D:\RedisPoc\config\redis.js:18:1)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)

With:

Redis 5.0.0
"redis": "^2.8.0",
"redis-commands": "^1.4.0",
"redis-rejson": "^1.0.0"
npm 6.4.1

How I can resolve it ?

Can you post your code?

Slooo commented

same problem

`
const redis = require('redis');
const rejson = require('redis-rejson');

rejson(redis);

const client = redis.createClient();
client.json_set('order', '{ "name": "Apple", "description": "grey phone" }', redis.print);

`

@Muntzer Your second example is correct. You must run rejson(redis) before creating your client. You would then run the ReJSON commands as normal as methods in the client object.

I'm updating the README with more example code to clarify this.

@Slooo Your problem doesn't actually sound the same as @Muntzer. Open a new issue please.

@stockholmux , thanks for your help.