node-mysql2
node-mysql2 copied to clipboard
TypeError: LRU is not a constructor
I believe there is a conflict version with the lru-cache package. After some digging noticed that lru-cache v8.0.0 is the only version that exports the class as "default" and that's how is refernced in the code
const LRU = require('lru-cache').default;
but if for some reason there is a version conflict on that library, which in my case happened you get that error. I also noticed that mysql2 has this dependeny "named-placeholders": "^1.1.3" but "named-placeholders dependecy is "lru-cache": "^7.14.1".
I'm nort sure why npm is not crying about this but in my case I'm getting lru-cache "5.1.1" which is even worst.
I fixed the issue by manually installing lru-cache v8.0.0
@wellwelwel I bumped lru-cache in named-placeholders ( need to publish it, last release action failed for some reason )
Couple of notes:
- need to revisit what stops us from using the very latest version ( 10.x now )
- 8.0.5 exports main class as both main export as well as
default
export so we may no longer need torequire('lru-cache').default
- maybe remove dependency altogether from named-placeholders and require users to bring your own cache? Would be a major version bump, and we'd need to change mysql2 side to pass cache constructor ( or cache instance ).
I bumped lru-cache in named-placeholders ( need to publish it, last release action failed for some reason )
Based on named-placeholders error:
✖ Error when creating branch
Error: release-please failed: Error creating Pull Request: Resource not accessible by integration
Possibly that's it:
Settings > Actions > General > Workflow permissions
need to revisit what stops us from using the very latest version ( 10.x now )
Looking at the LRU Cache breaking changes:
v9
- Use named export only, no default export.
We could adapt the import.
v10
- cache.fetch() return type is now Promise<V | undefined> instead of Promise<V | void>. This is an irrelevant change practically speaking, but can require changes for TypeScript users.
It just changes a type (TypeScript) from undefined
to void
, so it shouldn't affect MySQL2 code 🙋🏻♂️
Same error for me: "LRU is not a constructor" but manually installing lru-cache at v8.0.0 did not resolve for me
npm ls lru-cache
├── [email protected]
├─┬ [email protected]
│ ├── [email protected] deduped
│ └─┬ [email protected]
│ └── [email protected]
Same error for me: "LRU is not a constructor" but manually installing lru-cache at v8.0.0 did not resolve for me
npm ls lru-cache ├── [email protected] ├─┬ [email protected] │ ├── [email protected] deduped │ └─┬ [email protected] │ └── [email protected]
I have same problem. How to solve it?
Same error for me: "LRU is not a constructor" but manually installing lru-cache at v8.0.0 did not resolve for me
npm ls lru-cache ├── [email protected] ├─┬ [email protected] │ ├── [email protected] deduped │ └─┬ [email protected] │ └── [email protected]
I have same problem. How to solve it?
I installed "lru-cache": "^11.0.0", and it fixed the issue