Both packages help you create web servers to serve your files and applications, but they serve different purposes. Express is a full-featured web framework that lets you build complex web applications with routes, middleware, and APIs. HTTP-Server is a much simpler tool that just creates a basic server to show static files like HTML, CSS, and JavaScript during development.
Express is a full-fledged web framework with features like routing, middleware, and template engines, while http-server is a simple HTTP server that serves static files.
Express has official TypeScript support, while http-server does not.
Both packages are server-side, so they don't have browser compatibility issues.
Express has 30 dependencies, while http-server has 10 dependencies.
Express is more performance-oriented, with features like caching and compression, while http-server is lightweight and simple.
Express is compatible with most frameworks, including React, Angular, and Vue, while http-server is mostly used for serving static files.
Express has a very active community, with many contributors and a large ecosystem, while http-server has a smaller community.
Express has excellent documentation, with many tutorials and guides, while http-server has basic documentation.
Express is actively maintained, with frequent updates, while http-server is maintained by a single developer.
1const express = require('express');
2const app = express();
3app.get('/', (req, res) => {
4 res.send('Hello World!');
5});
6app.listen(3000, () => {
7 console.log('Server started on port 3000');
8});
This code creates a simple Express server that listens on port 3000 and responds with 'Hello World!' to GET requests.
1const httpServer = require('http-server');
2const server = httpServer.createServer();
3server.listen(3000, () => {
4 console.log('Server started on port 3000');
5});
This code creates a simple http-server that listens on port 3000 and serves static files.
Express is a more powerful and feature-rich package, while http-server is lightweight and simple.
A super fast web framework for Node.js that's similar to Express but with better performance. It's designed to be as fast as possible while keeping developer-friendly features.
Perfect for Express users who want better speed. It has a similar API to Express but can handle more requests per second. Also has great TypeScript support and is actively maintained.
Web FrameworkA tiny and super easy static file server that's perfect for local development. Just one command to serve your files, with zero configuration needed.
Much simpler than http-server but just as effective for basic needs. Has a clean interface and works great for quick local development and testing.
Static File ServerA lightweight web framework created by the Express team. It uses modern JavaScript features like async/await and has a simpler, more streamlined approach to handling requests.
Great for Express users who want something more modern. Uses newer JavaScript features and has a cleaner way to handle middleware. Good for smaller applications.
Web FrameworkA simple development server with live reload capability. When you change your files, the browser automatically refreshes to show your changes.
Better than http-server when you're actively developing because it automatically refreshes your browser. Perfect for frontend development.
Development ServerA rich framework for building applications and services. It's more structured than Express and comes with many built-in features like input validation and caching.
Good alternative to Express for larger projects that need more structure. Has many features built-in that you'd need to add separately in Express.
Web FrameworkFast, unopinionated, minimalist web framework for Node.js.
This project has a Code of Conduct.
const express = require('express') const app = express() app.get('/', function (req, res) { res.send('Hello World') }) app.listen(3000)
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
If this is a brand new project, make sure to create a package.json
first with
the npm init
command.
Installation is done using the
npm install
command:
$ npm install express
Follow our installing guide for more information.
PROTIP Be sure to read Migrating from 3.x to 4.x as well as New features in 4.x.
The quickest way to get started with express is to utilize the executable express(1)
to generate an application as shown below:
Install the executable. The executable's major version will match Express's:
$ npm install -g express-generator@4
Create the app:
$ express /tmp/foo && cd /tmp/foo
Install dependencies:
$ npm install
Start the server:
$ npm start
View the website at: http://localhost:3000
The Express philosophy is to provide small, robust tooling for HTTP servers, making it a great solution for single page applications, websites, hybrids, or public HTTP APIs.
Express does not force you to use any specific ORM or template engine. With support for over 14 template engines via Consolidate.js, you can quickly craft your perfect framework.
To view the examples, clone the Express repo and install the dependencies:
$ git clone https://github.com/expressjs/express.git --depth 1 $ cd express $ npm install
Then run whichever example you want:
$ node examples/content-negotiation
The Express.js project welcomes all constructive contributions. Contributions take many forms, from code for bug fixes and enhancements, to additions and fixes to documentation, additional tests, triaging incoming pull requests and issues, and more!
See the Contributing Guide for more technical details on contributing.
If you discover a security vulnerability in Express, please see Security Policies and Procedures.
To run the test suite, first install the dependencies, then run npm test
:
$ npm install $ npm test
The original author of Express is TJ Holowaychuk