Express is a web framework that is provided to facilitate efficient development of Node.js applications. You can use Express to develop API-based applications, Web applications, backend applications, and other applications. This topic describes how to develop a simple Express application and deploy the application in Web+.


A Node.js environment is configured. For more information, see Configure a Node.js development environment.

Step 1: Install express-generator

In this example, express-generator is used to create an Express project. Use the following command to install express-generator.
npm install -g express-generator
Note If you have installed Node.js 8.2.0 or later, you can skip this step and use the npx command to run express-generator when creating an application.

Step 2: Create an application.

Use the following command to create an application named webplus-express-app.
express webplus-express-app
Note If you have installed Node.js 8.2.0 or later, you can use the npx express-generator webplus-express-app command to run express-generator. You do not need to manually install express-generator.
A directory named webplus-express-app is created. The structure of the directory is as follows.
├── app.js
├── bin
│   └── www
├── package.json
├── public
│   ├── images
│   ├── javascripts
│   └── stylesheets
│       └── style.css
├── routes
│   ├── index.js
│   └── users.js
└── views
    ├── error.jade
    ├── index.jade
    └── layout.jade

Step 3: Install local dependencies

  1. Use the following command to go to the webplus-express-app directory.
    cd webplus-express-app
  2. Use the following command to install local dependencies.
    npm install

Step 4: Start the application on the localhost

  1. Use the following command to start the application on the localhost. Check whether the application performs as expected.
    npm start
    A successful start of the application is indicated if the following message is displayed on the command prompt.
    > webplus-express-app@0.0.0 start /home/admin/webplus-express-app
    > node ./bin/www
  2. View the result.
    • Open a browser and enter http://localhost:3000 in the address bar to visit the homepage of the application.
    • Use the curl http://localhost:3000 command to view the result that is returned.
      <! DOCTYPE html>
              <title>Developer Guide</title>
              <link rel="stylesheet" href="/stylesheets/style.css">
              <p>Welcome to Express</p>
      Note The original message is displayed by using single-line text. However, the returned message provided here is formatted for readability.
  3. You can press CTRL+C to stop the service after viewing the running result of the application.

Step 5: Package the application

Use the following command to archive the project directory where the application resides.
zip -r .
Notice The archive file must include the node_modules sub-directory and cannot contain the project directory, which is webplus-express-app. The following figure shows the structure of directories that are included in an example archive file.

Step 6: Deploy the application in Web+

  1. Log on to the Web+ console.
  2. On the Overview page, click Create in the upper-right corner of the Last Updated Deployment Environments section.
  3. In the Basic Information step, select Node.js in the Technology Stack Type field, enter an application name and description, and then click Next.
  4. In the Deployment Environment Information step, enter a deployment environment name, select Upload Local Application in the Deployment Package Source field, upload the deployment package, modify the package version, and click Create with Low Cost Preset.
  5. In the Creation Complete step, click View Application or Creation Complete to go to the Overview tab of the Application Details page. Click the name of a deployment environment to go to the Overview tab of the Deployment Environment Details page. Then, click the link next to the Public IP Address label to visit the homepage of the application.

More information