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

Class constructor LRUCache cannot be invoked without 'new' #25

Open
mattanimation opened this issue Mar 6, 2021 · 3 comments
Open

Class constructor LRUCache cannot be invoked without 'new' #25

mattanimation opened this issue Mar 6, 2021 · 3 comments

Comments

@mattanimation
Copy link

node version: v14.15.0 via nvm
version: 1.6.4

I get this error when attempting to use the memorystore.

Class constructor LRUCache cannot be invoked without 'new' {
  "stack": "TypeError: Class constructor LRUCache cannot be invoked without 'new'\n    at new MemoryStore (/node_modules/memorystore/lib/memorystore.js:78:1)

I did add the new on line 78 and re-built and it does fix the error

my code sample

import session from 'express-session';
import createMemoryStore from 'memorystore';
...
const MemoryStore = createMemoryStore(session);
...

const expStoreConfig: session.SessionOptions = {
        secret: environment.session_secret,
        cookie: { maxAge: 86400000 },
        store: new MemoryStore({
          checkPeriod: 86400000
        }),
        resave: false,
        saveUninitialized: true
    };

change to line: 78
this.store = new LRU(this.options)

I could create a PR but the fix is so tiny, it might be faster on your end?

Note:

  • I am using nx and yarn to build and manage my packages
@roccomuso
Copy link
Owner

did you yarn install or npm install? what version of lru-cache did npm bring in when you installed?

@mattanimation
Copy link
Author

I did use yarn install to fetch it and it looks like it went with 6.0.0. I did notice on another thread for lru-cache that they had mentioned an update that now requires the new keyword. I noticed the version reference in this package.json is ^4.0.3 so maybe its just an update the version and adding the new on line 78

@roccomuso
Copy link
Owner

if you use the yarn install command the version installed should be 4.1.5 as stated in yarn.lock. So I don't know how you possibly fetched 6.0.0.

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