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}`));
- Npm run dev or nodemon
- Ctrl^ c
- Npm start
- Install Git using git init command
- Create a new file. git ignore to ignore the file and folder to upload i.e. node_modules/
- Git add.
- Git commit –m “message”