Help with: Install and Set Up Mongoose

Hello, I am struggling to get this challenge to work. If anyone can review my code and point out any errors, I would appreciate it.

Problem: The tests fail with the messages:

“mongodb” dependency should be in package.json (Test timed out)
“mongoose” dependency should be in package.json (Test timed out)
“mongoose” should be connected to a database (Test timed out)

Code in myApp.js:

const mongoose = require('mongoose');

mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

Code in 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.5.7",
    "mongoose": "^5.9.12"
  },
  "engines": {
    "node": "4.4.5"
  },
  "repository": {
    "type": "git",
    "url": "https://hyperdev.com/#!/project/welcome-project"
  },
  "keywords": [
    "node",
    "hyperdev",
    "express"
  ],
  "license": "MIT"
}

I have created an .env file with the following code (note password has been removed for the forum post but is correct in the actual .env without ‘<>’):

MONGO_URI='mongodb+srv://kapigeau:<password>@cluster0-dircc.gcp.mongodb.net/test?retryWrites=true&w=majority'

Thank you!

Edit: I was able to create and setup the database with no problems.

Link to the challenge:

Hello there.

The test timing out suggests the url you are passing in is not pointing to the active project.

  1. Are you sure you are passing in the live view URL and not the edit view?
  2. Before running the tests, open up the live view of the project, so that Glitch gets it up and running. ( I assume you are doing this in Glitch??)

Also, seeing any errors in the console could be useful.

Hope this helps

1 Like

Yes, I am working on Glitch. Thanks for the tip about checking the Glitch console. I forgot all about it.

The console pointed out a problem with the ‘Person’ variable that is built into the
myApp.js code for this challenge. It seems I had commented out the declaration at some point. Oops! Reactivating it solved the problem.

Thanks for your help!