run node project locally code example

Example 1: srart server js

require('dotenv').config();

const express = require('express');
const server = express();
const cors = require('cors');
const ejs = require('ejs');
const methodOverride = require('method-override');
const pg = require('pg');
const agent = require('superagent');

const client = new pg.Client(process.env.DATABASE_URL);

server.use(methodOverride('_method'));
server.use(express.static('./public'));
server.use(cors());
server.use(express.urlencoded({extended :true}));
server.set('view engine','ejs');

Example 2: run node app locally

// Run this command in your terminal to start your node application.
// Replace the tag with your applications main file name (ex index.js, main.js etc). 
// Add alternative a relative or absolute path before the name.

node <filename>.js