Install and Set Up Mongoose: "mongoose" should be connected to a database

Tell us what’s happening:
Describe your issue in detail here.
I am trying to install and setup mongoose for the first MongoDB challenge.
I have set up my Atlas account as per the instructions

I have updated my dependencies in my package.json:

    "dependencies": {
        "body-parser": "^1.15.2",
        "dotenv": "^8.2.0",
        "express": "^4.12.4",
        "mongodb": "^3.0.0",
        "mongoose": "^5.6.5"

I have added my .env MONGO_URI, and I did NOT use quotes for the URI value, as per previous discussions on this issue.

I used an all alphabetical password, as per previous discussions on this issue.

Here is the top of my myApp.js:

const mongoose = require('mongoose');
const mySecret = process.env['MONGO_URI'];

let Person;

mongoose.connect(mySecret, { useNewUrlParser: true, useUnifiedTopology: true });

Here is my console output:

> fcc-mongo-mongoose-challenges@0.0.1 start /home/runner/boilerplate-mongomongoose-3
> node server.js

Your app is listening on port 3000
(node:265) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of null
    at parseSrvConnectionString (/home/runner/boilerplate-mongomongoose-3/node_modules/mongodb/lib/core/uri_parser.js:50:23)
    at parseConnectionString (/home/runner/boilerplate-mongomongoose-3/node_modules/mongodb/lib/core/uri_parser.js:597:12)
    at connect (/home/runner/boilerplate-mongomongoose-3/node_modules/mongodb/lib/operations/connect.js:282:3)
    at /home/runner/boilerplate-mongomongoose-3/node_modules/mongodb/lib/mongo_client.js:260:5
    at maybePromise (/home/runner/boilerplate-mongomongoose-3/node_modules/mongodb/lib/utils.js:692:3)
    at MongoClient.connect (/home/runner/boilerplate-mongomongoose-3/node_modules/mongodb/lib/mongo_client.js:256:10)
    at /home/runner/boilerplate-mongomongoose-3/node_modules/mongoose/lib/connection.js:835:12
    at new Promise (<anonymous>)
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose-3/node_modules/mongoose/lib/connection.js:832:19)
    at /home/runner/boilerplate-mongomongoose-3/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose-3/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose-3/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose-3/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose-3/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose-3/myApp.js:8:10)
(node:265) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see (rejection id: 3)
(node:265) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: Install and Set Up Mongoose

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.