Express.js/ Node.js for beginners with example

Akshay Devkate
Nerd For Tech
Published in
2 min readDec 27, 2021

--

Photo by Lautaro Andreani on Unsplash

Pre requisite: IDE, node.js, express.js

What is Node?

Node.js opensource and cross platform javascript runtime envirnonment which allows us to create serverside tools and application. Node.js represents “Javascript everywhere” thereby unifying web application development using single programming language rather than using different programming languages for server and client side.

Creating a small Hello Node.js example.

  1. Open terminal in mac or command prompt in windows.
  2. Create a folder named nodeTest

mkdir nodeTest

3. Enter into the

cd nodeTest

4. Using a IDE create a file helloNode.js and write the following code into the helloNode.js file

5. save the file

Go to the terminal and start the server using following command

node helloNode.js

What is Express.js ?

Express is a lightweight framework that runs on top of Node.js’ web server capabilities to make APIs easier to use and add useful new features. With middleware and routing, it’s easy to structure the functionality of your project. It extends Node.js’ HTTP objects with useful functions. It makes it easier to render dynamic HTTP objects.

Creating small hello world with Express.

  1. Open terminal in mac or command prompt in windows.
  2. Create folder named ExpressTest.

mkdir ExpressTest

3. navigate into the folder using following command.

cd ExpressTest

4. Using a IDE create a file helloExpress.js and write the following code into the helloExpress.js file

5. Save the file and run the command

node helloExpress.js

Difference between Node and Express ?

node.js is a Javascript runtime environment that comes with a ton of libraries that are used to perform specialised task on the servers. And Express is one of such library built on node to perform the tasks.

--

--