Express App Setup - SEIR-59/course-wiki GitHub Wiki

Express App Setup

Setup structure and dependencies

  1. Create the directory: mkdir yourproject
  2. Change into that directory: cd yourproject
  3. Initialize as a git repository: git init
  4. Create the server.js file: touch server.js
  5. Initialize as an yarn package: yarn init
    • Make sure you select server.js as the entry point
    • Everything else is up to you
  6. Add express as a dependency: yarn add express
  7. If you have not already, add nodemone as a global dependency: yarn global add nodemon

OR

  1. Create the directory: mkdir yourproject
  2. Change into that directory: cd yourproject
  3. Run these commands:
    git init
    touch server.js
    yarn init --yes
    yarn add express
    yarn global add nodemon
    

Setup server.js

const express = require('express');
const app = express();

const PORT = 3000;

app.listen(PORT, () => { 
	console.log('app is running on port: ', PORT);
});