Express
Courses
Setup
Linux
Manual Setup
- Install Node: Guide
- Make a folder
express-demo
- Go to the folder
cd express-demo
npm init --yes
→ createspackage.json
npm i express
→ Install expressnpm i -D nodemon
→ Install nodemon as devDependency → nodemon reloads application on changes to the code- Create
app.js
in root directory - Add script to run app.js in
package.json
package.json
{
"scripts": {
"dev": "nodemon app.js",
"start" : "node app.js"
},
}
npm run dev
Run app in development modenpm run start
→ Run app in production mode
Express Generator Setup
- Install node
- Create folder
express-demo
- Go to the folder
cd express-demo
npx express-generator
→ Create boilerplate codenpm install
→ Install dependenciesnpm start
→ Start application
Express CLI Setup
- Install node
- Install express globally
npm i -g express
express express-demo
→ creates and runs express appnpm install
→ install dependenciesnpm start
→ run application