DEV Community

Cover image for Can't use redis with nodejs 18.13. Invalid or unexpected token?
Debanjan Tewary
Debanjan Tewary

Posted on

Can't use redis with nodejs 18.13. Invalid or unexpected token?

Nodejs Application Crashes by only importing redis. I am not even using it any where else.

Just import redis from "redis" is throwing me this error.

Node & Redis Version:

  1. ❯ node -v v18.13.0
  2. "redis": "^4.5.1"

This is my server index.js file:
index.js

Error:

/Users/debanjantewary/Desktop/YSG/server/node_modules/@redis/client/dist/lib/cluster/cluster-slots.js:65
            if (node.client.options?.readonly)
                                    ^

SyntaxError: Invalid or unexpected token
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)

Node.js v18.13.0
Enter fullscreen mode Exit fullscreen mode

Tried solution But didn't work:

Clear cache node
Re-install Node stable version
Enter fullscreen mode Exit fullscreen mode

Please help If anyone knows. Thank you ❤️

Top comments (1)

Collapse
 
adityavernekar profile image
Aditya Vernekar

hey , did you manage to get through this error ? Even i m getting the same error . Any help would be appreciated