db.sadd 不是一个函数。

huangapple go评论72阅读模式
英文:

db.sadd is not a function?

问题

I'm trying to run some Node.js examples from the Express GitHub repository at this link. For this specific example, I ran npm update and made sure that Redis in the root package.json is "redis": "^4.6.7". However, I'm encountering an error related to the sadd function not being present. I searched the Redis GitHub repository for sadd but couldn't find its function definition. Does anyone know what's happening or how to further debug this?

$ node index.js
/home/vboxuser/src/nr/express/examples/search/index.js:28
db.sadd('ferret', 'tobi');
   ^

TypeError: db.sadd is not a function
    at Object.<anonymous> (/home/vboxuser/src/nr/express/examples/search/index.js:28:4)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.13.0
英文:

I'm trying to run some Nodejs examples from the Express examples GitHub at this link.

For this linked example, I ran npm update and ensured Redis is in the root package.json is &quot;redis&quot;: &quot;^4.6.7&quot;, however am receiving the following error about sadd function not present. I searched Redis GitHub for sadd and did not see the function definition.

Does anyone know what is going on or how to debug this further?

$ node index.js
/home/vboxuser/src/nr/express/examples/search/index.js:28
db.sadd(&#39;ferret&#39;, &#39;tobi&#39;);
   ^

TypeError: db.sadd is not a function
    at Object.&lt;anonymous&gt; (/home/vboxuser/src/nr/express/examples/search/index.js:28:4)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.13.0

答案1

得分: 0

这个示例是不正确的。正确的函数名称是.sAdd.SADD。我通常使用.sAdd,因为在代码中全大写感觉奇怪。我强烈鼓励您向他们发送一个拉取请求。

如果您遇到其他类似的问题,您可以在Node Redis README中找到几乎所有内容。

英文:

This example is incorrect. The correct function name is .sAdd or .SADD. I usually go with .sAdd as all caps feels weird in code. I would heartily encourage you to send them a PR.

If you run into other issues like this, you can find the pretty much everything in or off of the Node Redis README.

huangapple
  • 本文由 发表于 2023年7月18日 06:00:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76708344.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定