ioanat94 / netflix

A full stack Netflix clone using React, Node, Express and MongoDB.
7 stars 5 forks source link

nodemon start error #2

Open RickSpider opened 4 months ago

RickSpider commented 4 months ago

using alma linux, I am new with mongodb and npm sorry xD

[nodemon] 3.1.0 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting node start index.js Backend server is running on port 5000 MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.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 () 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)

ioanat94 commented 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