i try to set up a MongoDB and get a connection to the Database with Node.js. I am currently working with a Raspberry Pi 2. And the MongoDB Version= 2.4.
If I try to execute this code:
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/mydb";
MongoClient.connect(url, function(err, db) {
if (err) throw err;
console.log("Database created!");
db.close();
});
I am getting this error:
MongoError: Server at localhost:27017 reports wire version 0, but this version of Node.js Driver requires at least 2 (MongoDB2.6).
And the Database looks like this:
{ "_id" : ObjectId("5aa1719e551ea6f4212f71c2"), "numer" : 1 }
{ "_id" : ObjectId("5aa1805aa17e0c953e4ec284"), "numer" : 1, "name" : "test" }
Maybe it is the Version of the Pi. But there must be other opportunities to do it.
Thanks for your help :)
This looks like a version compatibility issue between your node driver and your database. MongoDB 2.4 is rather old; recent versions of the node driver likely don't support versions earlier than MongoDB 2.6.
Trying updating to use a more recent version of MongoDB; MongoDB 2.4 is well past end-of-life.
Thanks for all the answers.
I found a workaround with docker on the raspberry pi.
For that, I installed hypriot (docker optimized pi os) on the pi and then I started a MongoDB docker container.
For more information: https://blog.hypriot.com/getting-started-with-docker-on-your-arm-device/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With