Follow this steps to create project using Node.js, Express.js, Mongoose.js and MongoDB Atlas

  1. Create Express.js project
npm install express-generator -g

2. Create an Express.js app
(This will create Express.js project with the EJS view)

express node-project -e

3. Go to created project

cd node-project
npm install
npm start

4. You will see the image saying 'Welcome to Express'
    Stop node by push CTRL+C

5. Install mongoose.js module

npm install mongoose --save

Open and edit app.js
Declare mongoose in require section

var mongoose = require('mongoose');
//Use mongoose with native Node Promise
mongoose.Promise = global.Promise;

6. Add MongoDB connection string

mongoose.connect('Your-MongoDB-Atlas-Connection-String')
  .then(() =>  console.log('MongoDB Succesfully Connected'))
  .catch((err) => console.error(err));

Run node project again 'npm start'
You should see 'MongoDB Succesfully Connected'


Setting Up MongoDB Atlas

  1. Create new account on MongoDB Atlas
  2. Click on Create New project and name your project as'Project-1'

3. Add Members and Set Permission and Click next to create project.

4. Click on Build a Cluster

5. Click on create cluster.
(You can change default configurations)

6. Click on connect to get the connection string.

7. Choose your connection method.

8. Add this connection string to mongoose.connect()