DEV Community

Cover image for How to install Express.js in VS code in 2025
Prashanth K.S
Prashanth K.S

Posted on

How to install Express.js in VS code in 2025

To install the Express framework on Visual Studio Code (VS Code), follow these steps:


1. Install Node.js

Express is a Node.js framework, so you need Node.js installed.

  • Download and install Node.js from nodejs.org (LTS version recommended).
  • Verify the installation:
  node -v   # Check Node.js version  
  npm -v    # Check npm version  
Enter fullscreen mode Exit fullscreen mode

2. Open VS Code and Set Up a Project

  • Open Visual Studio Code.
  • Create a new folder for your project (e.g., express-app).
  • Open the folder in VS Code:
  cd path/to/express-app
  code .
Enter fullscreen mode Exit fullscreen mode

3. Initialize a Node.js Project

Inside VS Code’s terminal, run:

npm init -y
Enter fullscreen mode Exit fullscreen mode

This creates a package.json file.


4. Install Express

Run the following command:

npm install express
Enter fullscreen mode Exit fullscreen mode

This will install Express and save it in node_modules.


5. Create a Basic Express Server

  • In your project folder, create a new file: index.js.
  • Add this code to set up a simple Express server:
  const express = require('express');
  const app = express();

  app.get('/', (req, res) => {
      res.send('Hello, Express!');
  });

  app.listen(3000, () => {
      console.log('Server is running on http://localhost:3000');
  });
Enter fullscreen mode Exit fullscreen mode

6. Run the Express Server

In the terminal, start the server:

node index.js
Enter fullscreen mode Exit fullscreen mode

Now, open http://localhost:3000/ in your browser, and you should see "Hello, Express!".


Optional: Use Nodemon for Auto-Restart

To avoid restarting manually after code changes, install nodemon:

npm install -g nodemon
Enter fullscreen mode Exit fullscreen mode

Then, run your server with:

nodemon index.js
Enter fullscreen mode Exit fullscreen mode

Now, you have Express installed and running on VS Code! 🚀

Top comments (0)