Express.js Installation
This page walks through setting up a new Express project from scratch.
Check Node and npm are installed
Before you start, confirm Node.js and npm are available:
node -v
npm -v
If either command fails, install Node.js from nodejs.org . npm is bundled with Node.
Create the project folder and package.json
mkdir my-project
cd my-project
npm init -y
npm init -y creates a package.json file with default values. This file tracks your project’s dependencies and scripts.
Install Express
npm install express
This adds Express to dependencies in package.json and downloads it into node_modules/.
Install nodemon for development
Nodemon watches your files and restarts the server automatically whenever you save a change. Install it as a development dependency:
npm install -D nodemon
Add npm scripts
Open package.json and add start and dev scripts:
{
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
}
}
npm start: runs the app with Node (for production or quick checks)npm run dev: runs the app with nodemon (for development, auto-restarts on save)
Test with Postman
Postman is a desktop app for sending HTTP requests to your server. It lets you test GET, POST, PUT, and DELETE endpoints without building a frontend. Download the free version from their website.
What to read next
- Creating an Express App : write your first Express server