Application Setup in Node.js

From the Express.js cheat sheet · Setup & Basics · verified Jul 2026

Application Setup

Create and configure Express app

javascript
// Install
npm install express

// Basic setup
const express = require('express')
const app = express()
const PORT = process.env.PORT || 3000

// Middleware
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(express.static('public'))

// Start server
app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`)
})

// ES6 modules
import express from 'express'
💡 Use environment variables for configuration
✅ Set up middleware early in the app
⚡ Use compression in production
Back to the full Express.js cheat sheet