Mongoose connect is not a function... What is wrong?

I have tried to connect mongodb to REACT in a million different ways, using uri, putting the code straight on the ./app, doing the connection in another file and requiring it in the ./app page… nothing has worked.

I believe I have the username and password just fine, along with the database name…

Why am I keep getting these errors and not able to connect?

I have tried tons of different codes… this is just one of them…

const mongoose = require("mongoose");

const connection =

  "mongodb+srv://<myusernamehere>:<mypasswordhere>@cluster0.gcyyo.mongodb.net/<mydatabasehere>?retryWrites=true&w=majority";

mongoose

  .connect(connection, {

    useNewUrlParser: true,

    useUnifiedTopology: true,

    useFindAndModify: false,

  })

  .then(() => console.log("Database Connected Successfully"))

  .catch((err) => console.log(err));

Did you get through? Im trying with Svelte 3.49 and Vite 3.1.0 using ES6 and I get the same error. Tried lots of “solutions”. None work. So frustrating how krappy web software is. I developed software for years on pc and most of the time it krapped out was human error. Web software is bug infested!