npm init -y

Install packages

npm install express mongoose dotenv colors express-async-handler cors
  • Express for rest API
  • Mongoose for MongoDB ODM
  • dotenv for working with dotenv files
  • colors for seeing things better in the terminal
  • express-async-handler for handling exceptions inside async express routes and passing them to your express error handlers
  • cors for sharing resources between servers (backend) and clients (frontend)

Install nodemon as a dev dependency`

npm install -D nodemon

Create backend folder and server.js file inside it

Update package.json file

  "name": "quote-gen",
  "version": "1.0.0",
  "description": "A fullstack quote generator",
  "main": "server.js",
  "scripts": {
    "start": "node backend/server.js",
    "dev": "nodemon backend/server.js"
  "author": "Kolade Chris",
  "license": "MIT",
  "dependencies": {
    "colors": "^1.4.0",
    "dotenv": "^16.0.0",
    "express": "^4.17.3",
    "express-async-handler": "^1.2.0",
    "mongoose": "^6.2.4"
  "devDependencies": {
    "nodemon": "^2.0.15"

Put a test code inside server.js

console.log("Hello codecontinuers");

Run the development server

npm run dev //Output: Hello codecontinuers

This is what the folder structure looks like so far: