Create and run a local Node.js app

Previous step: Introduction and prerequisites

In this step, you create a simple Node.js app using the Express application generator. You then run the app locally.

  1. In a terminal or command prompt, navigate to a location where you want to create the app folder.

  2. Run the following command to create a new Express app named expressApp1 using the Express Generator. (The --view pug --git parameters tell the generator to use the pug template engine, formerly known as Jade, and to create a .gitignore file.)

    npx express-generator expressApp1 --view pug -–git
    
  3. Navigate into the app folder:

    cd expressApp1
    
  4. Install the application's dependencies:

    npm install
    
  5. Start the server:

    npm start
    
  6. Test the app by opening a browser to http://localhost:3000. The site should appear as follows:

    Running Express Application

  7. Press Ctrl+C in the terminal to stop the server.