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

Import issue (maybe es6 related) #7

Open
bill-o-more opened this issue Sep 2, 2023 · 0 comments
Open

Import issue (maybe es6 related) #7

bill-o-more opened this issue Sep 2, 2023 · 0 comments

Comments

@bill-o-more
Copy link

As per documentation, the way to import the MemoryCache class is

import { MemoryCache } from 'memory-cache-node';

which doesn't work because MemoryCache is exported as default - as per MemoryCache.d.ts:

export default class MemoryCache<K, V>

and the above import statement gives SyntaxError: The requested module 'memory-cache-node' does not provide an export named 'MemoryCache' error.

So the import that actually works is

import MemoryCache from 'memory-cache-node';

But then you gotta use it like

const cache = new MemoryCache.MemoryCache<string, number>(30, 50000);

otherwise you get TypeError: object is not a constructor.

I'm using es6 modules, if it's relevant.

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

1 participant