Setup Server for production and development Step – 3

Setup Server for production and development Step – 3

Step 3: -Setup Server for production and development

Create a new folder with name config and then inside it create new file with name config.env.

NODE_ENV=DEVELOPMENT

PORT=5000

Import and Use Dependency in server.js

// Import Dependency
const express = require('express');
const dotenv = require ('dotenv');

//Load environment variable into an object
dotenv.config({path:'./config/config.env'});

//Initialize App variable with express
const app =express ();

const PORT= process.env. PORT || 5000;

//to run server
app. listen (PORT,console.log(`Server running in ${process.env.NODE_ENV} 
Mode on port ${PORT}`));
  1. Npm run dev or nodemon
  2. Ctrl^ c
  3. Npm start
  4. Install Git using git init command
  5. Create a new file. git ignore to ignore the file and folder to upload i.e. node_modules/
  6. Git add.
  7. Git commit –m “message”

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*