- Install dependencies.
npm install
- Execute the script using following command :
node MongoDBConnect.js
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED]
Before running this script, make sure the mongodb server must be running on local machine.