Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: RedisStore is not a constructor #418

Open
J0hn3ch opened this issue Dec 11, 2024 · 1 comment
Open

TypeError: RedisStore is not a constructor #418

J0hn3ch opened this issue Dec 11, 2024 · 1 comment

Comments

@J0hn3ch
Copy link

J0hn3ch commented Dec 11, 2024

Hi everyone,

In one of my projects, a strange TypeError appear when I switch from Node.js v20.15.0 to Node.js v22.12.0 .
When I try to create a new RedisStore instance this type error occurs :

let redis_store = new RedisStore({
                  ^

TypeError: RedisStore is not a constructor
    at Object.<anonymous> (/home/***/db.js:164:19)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/***/app.js:27:25)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)

Node.js v20.15.0

I find that the error can be solved using const { RedisStore } = require("connect-redis"); in the project with Node.js v22.12.0 with connect-redis version ^8.0.1.


Previously I used const RedisStore = require("connect-redis").default; in the project with Node.js v20.15.0 with connect-redis version ^7.1.1

Is there some reason why I cannot use the the same line of code in both version ?

@wavded
Copy link
Collaborator

wavded commented Dec 11, 2024

I am running Node 23 currently without issues. Do you have a small project that duplicates this issue?

Is there some reason why I cannot use the the same line of code in both version ?

We ran into compatibility issues between CommonJS and ESM projects, this makes one common API. (see #411)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants