Skip to content

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

@mattanimation

Description

@mattanimation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions