ITADN

TypeError: RedisStore is not a constructor

#418ClosedJ0hn3ch 创建于 2024-12-11
J
J0hn3chcommented
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 ?
关闭于 2025-02-17 11 条评论