sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
3.94k stars 592 forks source link

TypeError: LRU is not a constructor #2619

Open jasmasher opened 3 weeks ago

jasmasher commented 3 weeks ago

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

sidorares commented 2 weeks ago

@wellwelwel I bumped lru-cache in named-placeholders ( need to publish it, last release action failed for some reason )

Couple of notes:

wellwelwel commented 2 weeks ago

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

Screenshot 2024-04-26 at 01 22 45
wellwelwel commented 2 weeks ago

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 🙋🏻‍♂️