Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5184

Uncaught TypeError in mongo_types.ts

    • Type: Icon: Question Question
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 5.2.0
    • Component/s: TypeScript
    • 0
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      When trying to connect to my Atlas database in a Node project that I set up using Vite, I get the error in the attached screenshot. Since Vite does not allow "require" statements out of the box, I changed the import to "import { MongoClient, ServerApiVersion } from "mongodb";". 

       

      I have tried this on both Node v16.19.0 and v18.15.0 and get the same result. I tried to connect using the code sample provided by Atlas, as well as the code samples provided in the documentation [here|https://www.mongodb.com/docs/drivers/node/current/quick-start/connect-to-mongodb/|https://www.mongodb.com/docs/drivers/node/current/quick-start/connect-to-mongodb/].] and here 

        1. mongo_types Developer Tools.png
          72 kB
          Brett N/A
        2. package json.png
          150 kB
          Brett N/A
        3. Uncaught TypeError.png
          64 kB
          Brett N/A

            Assignee:
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Reporter:
            bspangler21@alumni.uwosh.edu Brett N/A
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: