GithubHelp home page GithubHelp logo

Comments (10)

isaacs avatar isaacs commented on June 2, 2024

Can you run npm ls lru-cache to verify?

from node-lru-cache.

isaacs avatar isaacs commented on June 2, 2024

And if it is 9.1.1, run npm why lru-cache to verify that nothing else is getting the wrong version.

from node-lru-cache.

TroyCoombs avatar TroyCoombs commented on June 2, 2024

npm ls lru-cache gives this,

├─┬ @google-cloud/[email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected]
├─┬ @google-cloud/[email protected]
│ └─┬ [email protected]
│   └── [email protected]
├─┬ @google-cloud/[email protected]
│ └─┬ [email protected]
│   └── [email protected]
├─┬ @typescript-eslint/[email protected]
│ └─┬ [email protected]
│   └── [email protected]
├─┬ [email protected]
│ └── [email protected]
└── [email protected]

from node-lru-cache.

isaacs avatar isaacs commented on June 2, 2024

If you open up node_modules/lru-cache/dist/cjs/index.js in an editor, do you see class LRUCache { on line 139, and exports.LRUCache = LRUCache; on line 1394?

If you open up node_modules/lru-cache/dist/mjs/index.js in an editor, do you see export class LRUCache { on line 136?

from node-lru-cache.

isaacs avatar isaacs commented on June 2, 2024

Also, if you add console.log(require.resolve('lru-cache')) to your program, what does it output?

from node-lru-cache.

TroyCoombs avatar TroyCoombs commented on June 2, 2024

Regarding this,

If you open up node_modules/lru-cache/dist/cjs/index.js in an editor, do you see class LRUCache { on line 139, and exports.LRUCache = LRUCache; on line 1394?

If you open up node_modules/lru-cache/dist/mjs/index.js in an editor, do you see export class LRUCache { on line 136?

the answer us yes to all of it.

And regarding this,

Also, if you add console.log(require.resolve('lru-cache')) to your program, what does it output?

I get /core/server/node_modules/lru-cache/index.js

from node-lru-cache.

isaacs avatar isaacs commented on June 2, 2024

Ok. Then the lru-cache that your program is loading is definitely not v9.1.1.

I'm not sure how you're building the deps for your server, but what it's getting is an old version.

from node-lru-cache.

seranus avatar seranus commented on June 2, 2024

I'm got hit with the same issue when migrating from webpack to vite with interop set to true

While debugging raw JS it seems that it's loading the proper version and it's properly initialized when for my own code.

Error seems to happen with SemVer dependency not loading an older version for it's range function
range = Range2; const LRU = LRUCache; const cache2 = new LRU({ max: 1e3 });

compared to my code
this.cache = new LRUCache.LRUCache(cacheOptions);

from node-lru-cache.

isaacs avatar isaacs commented on June 2, 2024

If your package manager or rollup builder isn't providing libraries with dependencies in their stated version ranges, there's not much I can do about that as the library author. Sounds like a vite bug.

from node-lru-cache.

dceddia avatar dceddia commented on June 2, 2024

I got a similar error, "LRUCache is not a constructor". The weird thing in my case was that it was working fine on my Mac, but not my Windows dev machine (mine's a Tauri app running everything in a webview so I'm building on both). I'm using Vite as well.

The comment that it might be picking the wrong version gave me the feeling that maybe it's some weird module resolution issue, so I blew everything away with rm -rf node_modules and re-ran yarn and the error went away! Pretty unsatisfying fix, but worth a shot anyway.

from node-lru-cache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.