Express sits on top of Node.js HTTP handling and adds routing, middleware, and response helpers for web services. A minimal server is enough when you need a local endpoint to test route wiring before adding templates, databases, or deployment tooling.

A starter app can use a normal npm project, install Express as a local dependency, and keep the server in one CommonJS file. Binding to 127.0.0.1 keeps the development listener local to the machine while you prove the route with curl.

The server reads PORT from the environment and falls back to port 3000, which matches the conventional Express starter port. Keep this pattern for local development; production deployments usually add process management, logging, reverse proxy settings, and shutdown handling.

Steps to create an Express server in Node.js:

  1. Create a project directory for the Express app.
    $ mkdir express-demo
  2. Enter the project directory.
    $ cd express-demo
  3. Initialize package metadata with npm.
    $ npm init --yes

    The command writes package.json with default metadata. Edit the name, license, or scripts later if the project needs specific values.

  4. Install Express as a local dependency.
    $ npm install express
    added 67 packages, and audited 68 packages in 2s
    
    25 packages are looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
  5. Create the Express app file.
    $ cat > app.js <<'EOF'
    const express = require('express');
    
    const app = express();
    const port = process.env.PORT || 3000;
    
    app.get('/', (req, res) => {
      res.type('text').send('Express server ready\n');
    });
    
    app.listen(port, '127.0.0.1', () => {
      console.log(`Express server listening at http://127.0.0.1:${port}`);
    });
    EOF

    process.env.PORT lets a deployment or test runner choose another port while local runs fall back to 3000.

  6. Confirm Express is saved in the project dependency tree.
    $ npm list express --depth=0
    express-demo@1.0.0 /home/developer/express-demo
    `-- express@5.2.1
  7. Start the Express app.
    $ node app.js
    Express server listening at http://127.0.0.1:3000

    Keep this terminal open while testing the route.

  8. Request the root route from another terminal.
    $ curl -sS http://127.0.0.1:3000/
    Express server ready
  9. Return to the server terminal and press Ctrl-C.