Question: I tried to set up a mongodb system with my openlayers map, but it is not working : Uncaught TypeError: Cannot read property 'db' of null. My part of code about mongodb is : 

```
    var MongoClient = require('mongodb').MongoClient;
    var url = "mongodb://localhost:27017/";
    MongoClient.connect(url, function(err, db) {
            var tapDB = db.db("tapDB"); //<-- here is the error

})

```

I suppose that this error is maybe because i am using npm start instear of node server.js, but I am not sure because i am a newbie. Mongodb is started via the cmd by doing the following command :"mongod" and then mongo on an other cmd.

**UPDATE**: For everyone having the same problem than me, i'd recommand deleting parcel. That's what I did and now it works fine

Answer: 
I believe you are currently providing the `url` in the wrong place - you need to provide the URL to `MongoClient` before calling `.connect`. As per MongoDB's Node.js Driver documentation it should look think this:

```
const MongoClient = require('mongodb').MongoClient;

const url = 'mongodb://localhost:27017';
const dbName = 'tapDB';
const client = new MongoClient(url);

client.connect(function(err) {
  console.log("Connected successfully to server");
  const db = client.db(dbName);

  // use database connection here

  client.close();
});

```

Have a look a the documentation here: <http://mongodb.github.io/node-mongodb-native/3.2/tutorials/connect/>

**UPDATE:**

You can also do the above using ES6 async/await which is in the long run simpler to use than a callback or native promises, this is our setup:

```
const MongoClient = require('mongodb').MongoClient;
const url = 'mongodb://localhost:27017';
const dbName = 'tapDB';

(async () => { // async/await function that will run immediately

  let client;
  try {
    client = await MongoClient.connect(url);
  } catch (err) { throw err; }
  console.log("Connected successfully to server");

  const db = client.db(dbName);

  let res;
  try {
    res = await db.collection("markers").insertMany([{ test1: true, test2: "3/5" }]);
  } catch (err) { throw err; }

  try {
    await client.close();
  } catch (err) { throw err; }
});

```
Using Javascript Promises ES6 is code is clearer

Look my code

```js
const {MongoClient} = require('mongodb');

MongoClient.connect('mongodb://localhost:27017', { useNewUrlParser: true }).then(client => {
    console.log('Connected to MongoDB server')

    const db = client.db('dbName')

    // Here you can place your operations with the bd

    client.close();
}, e => console.log('Error to connect', e))

```

I hope I've helped

Good luck!