Hello! Help Wanted! Nodejs development environment. Connecting to the database in the Mongodb Atlass cloud
File: app.js
const express = require ('express')
const mongoose = require ('mongoose')
const path = require ('path')
const keys = require ('./ keys')
const port = process.env.PORT || 5000
const clientPath = path.join (__ dirname, 'client')
mongoose.connect (keys.mongoURI)
.then (() => console.log ('MongoDB connected.'))
.catch (err => console.error (err))
const app = express ()
app.use (express.static (clientPath))
app.listen (port, () => { console.log (`The server started on the port $ {port}`) })
**File:keys.js**
module.export = {
mongoURI:'mongodb+srv://xxxusername:xxxpassword@cluster0-m3jmz.mongodb.net/mdbtest?retryWrites=true'
}
**An error is displayed in the terminal:**
C:\Users\user\Desktop\fullstack-blog\node_modules\mongoose\lib\connection.js:459
throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
^
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.co
nnect()` or `mongoose.createConnection()` is a string.
at new MongooseError (C:\Users\user\Desktop\fullstack-blog\node_modules\mongoose\lib\error\mongooseError.js:14:11)
at NativeConnection.Connection.openUri (C:\Users\user\Desktop\fullstack-blog\node_modules\mongoose\lib\connection.js:459:11)
at Mongoose.connect (C:\Users\user\Desktop\fullstack-blog\node_modules\mongoose\lib\index.js:289:15)
at Object.<anonymous> (C:\Users\user\Desktop\fullstack-blog\app.js:9:10)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
[nodemon] app crashed - waiting for file changes before starting...
Please help who can. Iām new, Iām learning)