I am having trouble getting the node-mongodb-native drivers to play nice. I’ve installed everything, all tests run correctly but when I try and run any of the examples I get a null error on the function. e.g.:
TypeError: Cannot call method ‘remove’ of null
Mongo shows that a connection is made, a function called then the connection closes. I have tried mongodb 1.4.5, 1.6.5 and 1.8.1 all with the same result.
Is there something else I should be doing to get the examples to run?
This means that you are trying to do a
removebut the collection did not initialize correctly.I assembled some sample code for a Node.JS + MongoDB + CloudFoundry blog post. There’s also some sample code on GitHub. The code is designed to work without CloudFoundry and simply run locally.
Take a look at the code that does the basic find:
Take a look at
coll.find, I’m assuming thatcollis correctly initialized. There’s a chance that it may not be initialized. If so, check theerrvariable and see what you’re getting. Also check theerrvariable at the level above that.