Hi Everyone,
I have been stuck on this challenge for over a week trying to figure out what I did wrong. Can anyone please point out where my error is?
This is my .env file
GLITCH_DEBUGGER=true
# Environment Config
# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values
# reference these in your code with process.env.SECRET
SECRET=
MADE_WITH=
MONGO_URI=mongodb://chrisjohnson0390:myPassword@ds123625.mlab.com:23625/freecodecamp_mongo
# note: .env is a shell file so there can't be spaces around =
This is my app.js
const mongoose = require("mongoose");
mongoose.connection.on("open", function(ref) {
console.log("Connected to mongo server.");
});
mongoose.connection.on("error", function(err) {
console.log("Could not connect to mongo server!");
return console.log(err);
});
const mongoURI = "mongodb://chrisjohnson0390:myPassword@ds123625.mlab.com:23625/freecodecamp_mongo";
const db = mongoose.connect(mongoURI, { useNewUrlParser: true });
And this 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",
"mongoose": "^5.1.6",
"mongodb": "^3.4.13"
},
"engines": {
"node": "4.4.5"
},
"repository": {
"type": "git",
"url": "https://hyperdev.com/#!/project/welcome-project"
},
"keywords": [
"node",
"hyperdev",
"express"
],
"license": "MIT"
}
When I run the test this is the error that I get:
// running tests
mongoose is not connected
Unexpected token < in JSON at position 0
Unexpected token < in JSON at position 0
// tests completed
Any help is greatly appreciated!!