shamahoque/mern-simplesetup

Does not play well with MongoDB 4.0

Closed this issue · 1 comments

I'm running MongoDB 4.0.9 and get the follwing error:

TypeError: Cannot read property 'close' of null
at eval (webpack:///./server/server.js?:58:6)
at err (/Users/carlos/Documents/node/mern-kickstart/node_modules/mongodb/lib/utils.js:411:14)
at executeCallback (/Users/carlos/Documents/node/mern-kickstart/node_modules/mongodb/lib/utils.js:401:25)
at err (/Users/carlos/Documents/node/mern-kickstart/node_modules/mongodb/lib/operations/mongo_client_ops.js:285:21)
at connectCallback (/Users/carlos/Documents/node/mern-kickstart/node_modules/mongodb/lib/operations/mongo_client_ops.js:265:5)
at server.connect (/Users/carlos/Documents/node/mern-kickstart/node_modules/mongodb/lib/operations/mongo_client_ops.js:353:14)
at Server. (/Users/carlos/Documents/node/mern-kickstart/node_modules/mongodb/lib/topologies/server.js:237:11)
at Object.onceWrapper (events.js:277:13)
at Server.emit (events.js:189:13)
at Pool. (/Users/carlos/Documents/node/mern-kickstart/node_modules/mongodb-core/lib/topologies/server.js:452:12)

All the node modules are the same as in the package.json here and in the book. The only difference is the MongoDB version. Updating the modules (the webpack modules in particular) won't work as it leads to Issue #3.

There is a simple workaround though. Simply run mongod --config /usr/local/etc/mongod.conf on a separate terminal window before running running the code.

This is not a MongoDB version issue.
Regardless of version, MongoDB must already be running on your system for this code to work - as specified in the 'How to run this code' instructions.