Express App Setup - SEIR-59/course-wiki GitHub Wiki
Express App Setup
Setup structure and dependencies
- Create the directory:
mkdir yourproject
- Change into that directory:
cd yourproject
- Initialize as a git repository:
git init
- Create the
server.js
file: touch server.js
- Initialize as an yarn package:
yarn init
- Make sure you select
server.js
as the entry point
- Everything else is up to you
- Add
express
as a dependency: yarn add express
- If you have not already, add
nodemone
as a global dependency: yarn global add nodemon
OR
- Create the directory:
mkdir yourproject
- Change into that directory:
cd yourproject
- 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);
});