I’ve been trying all day to figure out why I can’t get Mongoose connected to the database I set up. Can someone please help?
Here is my package.json:
{
"name": "fcc-mongo-mongoose-challenges",
"version": "0.0.1",
"description": "A boilerplate project",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.12.4",
"body-parser": "^1.15.2",
"mongodb": "^3.0.10",
"mongoose": "^5.1.6"
},
"engines": {
"node": "4.4.5"
},
"repository": {
"type": "git",
"url": "https://hyperdev.com/#!/project/welcome-project"
},
"keywords": [
"node",
"hyperdev",
"express"
],
"license": "MIT"
}
Here is my code in myApp.js:
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI);
My Uri is as follows (with user and pw redacted):
mongodb+srv://<user>:<password>@freecodecamptut-9ugnt.mongodb.net/test?retryWrites=true
I made sure that the password is alphanumeric (no special characters). I made sure to use the right glitch link for the course. My cluster seems to be set up appropriately. I’m getting this in the logs:
(node:1759) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 5 to freecodecamptut-shard-00-00-9ugnt.mongodb.net:27017 closed
at TLSSocket.<anonymous> (/rbd/pnpm-volume/462af9df-b212-4972-bd17-dbf24b09468f/node_modules/.registry.npmjs.org/mongodb-core/3.1.11/node_modules/mongodb-core/lib/connection/connection.js:276:9)
at Object.onceWrapper (events.js:273:13)
at TLSSocket.emit (events.js:187:15)
at _handle.close (net.js:610:12)
at TCP.done (_tls_wrap.js:386:7)
(node:1759) 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(). (rejection id: 1)
(node:1759) [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.
Any help would be greatly appreciated. Thanks in advance!