Open RickSpider opened 4 months ago
Hey! It's been a while since I worked on this, but the error is coming from here:
mongoose.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
Since it says your uri
is undefined I assume you don't have a process.env.MONGO_URL
. Make sure you have a .env
file in the root of your project with your MongoDB connection string in it, something like this:
MONGO_URL=mongodb+srv://username:password@domain.mongodb.net/?retryWrites=true&w=majority&appName=MyApp
using alma linux, I am new with mongodb and npm sorry xD
[nodemon] 3.1.0 [nodemon] to restart at any time, enter)
at promiseOrCallback (/opt/netflix/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (/opt/netflix/node_modules/mongoose/lib/index.js:1181:10)
at Mongoose.connect (/opt/netflix/node_modules/mongoose/lib/index.js:341:20)
at Object. (/opt/netflix/index.js:13:4)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
rs
[nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,cjs,json [nodemon] startingnode start index.js
Backend server is running on port 5000 MongooseError: Theuri
parameter toopenUri()
must be a string, got "undefined". Make sure the first parameter tomongoose.connect()
ormongoose.createConnection()
is a string. at Connection.openUri (/opt/netflix/node_modules/mongoose/lib/connection.js:689:11) at /opt/netflix/node_modules/mongoose/lib/index.js:342:10 at /opt/netflix/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5 at new Promise (