Reputation: 11
Error Message:
When running Mongoose, I encounter the following error message:
[nodemon] 3.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node server.js`
/home/harithriyadh/prayer-
tracker/node_modules/mongoose/node_modules/mongodb/lib/admin.js:62
session: options?.session,
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/harithriyadh/prayer-
tracker/node_modules/mongoose/node_modules/mongodb/lib/index.js:6:17)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:1027:10)
[nodemon] app crashed - waiting for file changes before starting...
DB Connection File:
Here is the file responsible for connecting to the database:
const mongoose = require("mongoose");
const dbUrl =
"mongodb+srv://username:[email protected]/?
retryWrites=true&w=majority";
const connectionParams = {
useNewUrlParser: true,
useUnifiedTopology: true,
};
mongoose
.connect(dbUrl, connectionParams)
.then(() => {
console.info("Connected to the DB");
})
.catch((e) => {
console.log("Error:", e);
});
Upvotes: 0
Views: 92