Importing mongodb in a vite project giving errors

import { MongoClient } from 'mongodb'

gives this error

mongodb.js?v=62540b6b:11524 Uncaught TypeError: Class extends value undefined is not a constructor or null
    at node_modules/mongodb/lib/cursor/abstract_cursor.js (mongodb.js?v=62540b6b:11524:55)
    at __require2 (chunk-XUG3XOB4.js?v=62540b6b:19:50)
    at node_modules/mongodb/lib/cursor/aggregation_cursor.js (mongodb.js?v=62540b6b:11580:29)
    at __require2 (chunk-XUG3XOB4.js?v=62540b6b:19:50)
    at node_modules/mongodb/lib/collection.js (mongodb.js?v=62540b6b:13172:32)
    at __require2 (chunk-XUG3XOB4.js?v=62540b6b:19:50)
    at node_modules/mongodb/lib/change_stream.js (mongodb.js?v=62540b6b:28014:24)
    at __require2 (chunk-XUG3XOB4.js?v=62540b6b:19:50)
    at node_modules/mongodb/lib/index.js (mongodb.js?v=62540b6b:29524:27)
    at __require2 (chunk-XUG3XOB4.js?v=62540b6b:19:50)

this thing is delaying project’s deadline

Hey @Vamp_S,

Welcome to the MongoDB Community forums :sparkles:

As I can see this issue seems to be related to this - discussed earlier in ViteJS - GitHub issue. Could you check if the suggested workaround resolves your issue or not?

Regards,
Kushagra

why vite doesn’t allow us to use vuejs with MongoDB and always throw error like promises , bson and etc

and MongoDB developers doesn’t like vite and vise versa.
in my last two projects i was thinking using MongoDB but because if not getting answers from your support team im using mysql and API servers for non important data
update yourself