TypeError: Cannot read property 'connect' undefined

'use strict';

var MongoClient;
MongoClient = require('mongodb').MongoClient();

MongoClient.connect(
'mongodb://127.0.0.1:27017/accounting',
function (err, connection){
    var collection = connection.collection('customers');

    collection.insert({'name': 'John Doe'}, function(err, count){

        collection.find().toArray(function(err, documents){
            console.dir(documents);
            connection.close();
        });

    });

});

Immer diese Fehlermeldung, wenn mit diesem code würde ich gerne wissen was den Fehler verursacht und mögliche Korrekturen.

TypeError: Cannot read property 'connect' of undefined
at Object.<anonymous> (C:\Users\Matt\WebstormProjects\keyword-wrangler\index.js:6:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

Nicht ganz sicher, was die Ursache dieses, ich bin mit WebStorm und installiert haben die neueste version von mongodb.

was MongoClient = new require('mongodb').MongoClient() ?
Kein Glück.. 🙁

InformationsquelleAutor Matt | 2016-06-19

Schreibe einen Kommentar