Can't connect to MongoDB from Glitch

@mishavee If i keep the full connection string, it says: Could not find Node *, using Node 10.

Ohhh this sounds familiar! I think this might help you:


or, maybe (if your package.json isn’t valid)

I agree with @househaunt.

In packages.json, if I set to the same as yours …

"engines": {
  "node": "*"
},

Then I get the same error Could not find node *, using 10

So try this instead …

"engines": {
   "node": "10.x"
},

You could also use “8.x” or “12.x”, depending on which version of Node you want to use.

Folks the “Could not find Node x” message isn’t really an error - it’s a confusingly-displayed warning telling you that we’re choosing a Node version for you since we couldn’t figure out which one you wanted. Unless your project’s code is Node version sensitive this isn’t something to be concerned about.

@RobotFights @mishavee’s suggestion will suffice to silence that message if it’s getting in the way, but it shouldn’t affect how your code runs at all (unless, as I mentioned, you need something other than Node 10).

1 Like

Thanks, that error is gone but now have another one saying: (node:6459) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
I did that and still saying not found. I think it has something to do with my MONGO_URI

I found that adding the following option to MongoClient.connect gets rid of the warning

useUnifiedTopology: true

Do you mean the Node engine warning?

When i try to pass the live app link to freecodecamp solution test. and how do i use the ‘useUnifiedtopology: true’ ? Cos already edited my code like this : mongoose.connect(process.env.MONGO_URI,{ useNewUrlParser: true });

Adding it to the options …

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

Edited it to the code above, still not going. if there’s another way for me to share my code since the live app link isn’t working.

This is how you share a link to your project to look at the code, I can see it … https://glitch.com/~fifth-blade


var mongodb = require('mongodb');
const mongoose = require('mongoose');

If you’re using mongoose, you are unlikely to also need to use the mongodb module. It shouldn’t stop the code working though.


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

Your code is very similar to mine, I didn’t need useUnifiedTopology for mongoose, for some reason.

My code …

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

Are you still getting a connection error in the console log?


Putting https://fifth-blade.glitch.me in the browser returns Not Found, this is because there are no routes setup yet, i.e. step 2 in the code is commented out.

Tried but still not working…