Getting Started with Express.js: Version 1 Lecture – Installing & Creating Hello World Program

Posted by

Learn Express.js | Lecture – 1: Installation & Hello World program

Welcome to Learn Express.js Lecture

In this lecture, we will learn about setting up Express.js and creating a simple “Hello World” program.

Installation

First, we need to install Express.js. This can be done using npm, the Node Package Manager, by running the following command in your terminal:

npm install express

Hello World Program

Once Express.js is installed, you can create a new JavaScript file, for example app.js, and write the following code to create a simple “Hello World” program:


const express = require('express');
const app = express();

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

app.listen(3000, () => {
console.log('Example app listening on port 3000!');
});

After writing the above code in your app.js file, you can run the program using the following command:

node app.js

Now, if you go to your web browser and navigate to http://localhost:3000, you should see “Hello World!” displayed on the page.

Conclusion

Congratulations! You have successfully installed Express.js and created a simple “Hello World” program. This is just the beginning of your journey in learning Express.js. Stay tuned for more lectures and tutorials on how to build powerful web applications using Express.js.