NodeJs - Hello World with Express


Hello World with Express

The following example uses Express to create an HTTP server listening on port 3000, which responds with "Hello, World!".

Express is a commonly-used web framework that is useful for creating HTTP APIs.

First, create a new folder, e.g. myApp. Go into myApp and make a new JavaScript file containing the following code (let's name it hello.js for example).

Then install the express module using npm install --save express from the command line. Refer to this documentation for more information on how to install packages.

From the command line, run the following command:

> node hello.js

Open your browser and navigate to http://localhost:3000 or http://127.0.0.1:3000 to see the response

For more information about the Express framework, you can visit https://expressjs.com

Comments