mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
The mongodb default import exposed MongoClient but NOT EJSON (mongodbPkg.EJSON was undefined), so the previous 'take EJSON from mongodb' attempt still hit the FATAL guard. Node 24's ESM default-interop for these CommonJS packages drops the getter/re-export used for EJSON. Switch to createRequire (CJS require returns the real module.exports with getters intact and honors NODE_PATH), and resolve EJSON by trying, in order: mongodb.EJSON, mongodb/lib/bson.js, mongodb/lib/bson, bare bson's .EJSON, and bare bson itself — falling back with a diagnostic list of what each attempt returned so a remaining failure names the cause instead of just 'undefined'. Thanks to xet7.