Any idea why i get this error?
this is the connect line
mongoose.connect("mongodb+srv://danielkmx:"+process.env.MONGO_ATLAS_PW+"@node-rest-shop-5xfup.mongodb.net/test",
{
useMongoClient:true
});
Any idea why i get this error?
this is the connect line
mongoose.connect("mongodb+srv://danielkmx:"+process.env.MONGO_ATLAS_PW+"@node-rest-shop-5xfup.mongodb.net/test",
{
useMongoClient:true
});
I think by now you have found an answer to this problem but I will explain, in the case that anyone else has the same problem
So generally we have 2 protocols(1- mongodb+srv:// & 2- mongodb://) right now to connect to a mongodb database.
the main difference between these 2 is the mongodb and its core version which you can find in the package-lock.json file, something like the code below:
"mongodb": {
"version": "3.0.0", //Your MongoDB version
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.0.0.tgz",
"integrity": "",
"requires": {
"mongodb-core": "3.0.0"
}
},
"mongodb-core": {
"version": "3.0.0", //Your MongoDB version
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.0.0.tgz",
"integrity": "",
"requires": {
"bson": "1.0.9",
"require_optional": "1.0.1"
}
},
This if you wanna use the mongodb+srv:// version then you need a driver of version 3.0.0 or higher which you can simply do by:
npm install mongodb@3.0.0
**Or higher
I hope you find this helpful and if this solution is working for you please confirm it that other users do not face our issue again
I agree with the solution and voted up for the question and very correct answers here.
In case someone wants to update the latest package(s), I suggest npm-check-updates (https://www.npmjs.com/package/npm-check-updates) for smooth updating.
Install npm-check-updates:
$ sudo npm install -g npm-check-updates
Check latest updates of the used packages:
$ ncu
Update packages:
$ ncu -u
Then, install the updated packages:
$ npm install
I faced the same problem but with mongorestore
command. I did brew update mongodb
which resulted in the following error.
unknown or unsupported macOS version: :mountain_lion
I then uninstalled mongodb and installed database tools by running brew install mongodb/brew/mongodb-database-tools
which solved the problem for me and I was able to restore the database using following command:
mongorestore --uri=mongodb+srv://<user>:<password>@cluster0.wtdv4.mongodb.net/<db-name> --db <db-name> <input-dir>