Not able to run mongoDB with node.js

Hi Community,

I am struck at a situation where I’m unable to go trough using mongo DB with node js.

My configuration version;

  1. Node.js: v18.16.0
  2. MongoDB: 6.0.6
    3.Mongosh: 1.9.0
  3. I have windows 10 with x64 machine

Now, I have done all the steps from;

  1. Installling latest version, as can be seen above.
    2.configuring environmental variables
  2. Creating C:/data/db
  3. Using instead of localhost

However, when working with following lines of code, I do following steps;

  1. Run mongod, in new terminal
  2. Run mongosh, in new terminal
  3. Run node app.js, new terminal

“node app.js” doesn’t givve any results and keeps on as it is.

Please help me here, I’m stuck here for 2 days straight without sleep, also I’m following a bootcamp where she made us create a .bash_profile which contained following lines but as of now I removed (didn’t work when present also);

alias mongod=“/c/Program\ files/MongoDB/6.0/bin/mongod.exe”
alias mongo=“/c/Program\ Files/MongoDB/6.0/bin/mongo.exe”

Also, refer to the code below and let me know my issue or bunder.

const mongoose = require (‘mongoose’);

mongoose.connect(‘mongodb://’, {useNewUrlParser: true, useUnifiedTopology: true});

const furitSchema = new mongoose.Schema({
name: String,
rating: Number,
review: String

const Fruit = mongoose.model(“Fruit”,furitSchema);

const fruit = new Fruit({
rating: 7,
review:“Pretty solid”

   const findDocuments = function(db, callback) {
    // Get the documents collection
    const collection = db.collection('fruits');
    // Find some documents
    collection.find({}).toArray(function(err, fruits) {
      assert.equal(err, null);
      console.log("Found the following records");


I found the solution:
Refer to this:

Even I am facing the same issue. Please help as it is a major block. No answer can be found any where