I'm running Mongoose 7.0.1 on Next JS 13.2.2 and React 18.2.0.
I've been looking high and low to find a solution to this issue. I just want to connect to a MongoDB, however, when I import mongoose to the project to connect. This error occurs. Am I doing something wrong? Error Log
So far I tried to fiddle with the importing process [ie. change from ES6 to Casual JS with "require"] I don't have a clue on what to do seeing as its in the Node Module itsself. I tried different versions of Mongoose as well. But to no avail.
EDIT >> Here's some screen shots of how I implemented mongoose library/mongo/index.ts app/api/route.ts
In next.config.js
file write the below code:
experimental: {
appDir: true,
serverComponentsExternalPackages: ["mongoose"],
},