MongoDB and Mongoose - Install and Set Up Mongoose

MongoDB and Mongoose - Install and Set Up Mongoose


Hi! I’m doing the first exercise from the “Mongo DB and Mongoose” section, but Glitch trows me the error " Error: Cannot find module ‘mongoose’ ".
My code for the dependencies on package.json is:
“dependencies”: {
“express”: “^4.16.3”,
“body-parser”: “^1.18.3”,
“mongoose”: “^5.1.6”,
“mongodb”: “^3.4.13”

And the code on MyApp,js:
const mongoose = require(‘mongoose’);

Any idea of what is wrong?



I tried your code and cannot replicate the error. May you post all the code?


The complete code of package.json is

  "name": "fcc-mongo-mongoose-challenges",
  "version": "0.0.1",
  "description": "A boilerplate project",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  "dependencies": {
    "express": "^4.16.3",
    "body-parser": "^1.18.3",
    "mongoose": "^5.1.6",
    "mongodb": "^3.4.13"
  "engines": {
    "node": "4.4.5"
  "repository": {
    "type": "git",
    "url": "!/project/welcome-project"
  "keywords": [
  "license": "MIT"

The only thing I add to myApp.js is

const mongoose = require('mongoose');

The rest of the code in that file is the Glitch code that was there when I open the project from the FreeCodeCamp section.

The code in .env is

MONGO_URI=mongodb://XXXX:[email protected]:49818/pruebabeloqui

where the Xs are the user and password of the database.


According to your error ,node is not abale to find the mongoose module so you can try this .

  1. First check whether you have multiple version or not . Sometime problem occur due to that .
  2. Re install all module for the project .

Then check in node shell for the mongoose .


I changed my dependencies to

"mongoose": "^5.1.6",
"mongodb": "^3.0.10"

and now it works. Thank you!


I had a problem in that my password used a key that wasn’t supported in the .env file. That character was one of these = [email protected]#$%^&*()

To solve it, I made another user, set the password to not contain one of the above symbols and then deleted the old user. When I just used numbers and letters in my username and password, I passed the tests.

Hope this helps! :smiley:


It also looks like you can’t use colons in your password, either. So can we only use letters and numbers?

EDIT: You can also use underscores…


It’s helpful, thank.

    "mongodb": "*",
    "mongoose": "*"


I know this post is old, but I had a similar problem and a similar fix. It seems that this exercise will not work with the current version of MongoDB. It has to be < version 4.0.


Thanks for this post. That helped. I had the same some special charater in the password :stuck_out_tongue: