'Coding has over 700 languages', '67% of programming jobs aren’t in the technology industry', 'Coding is behind almost everything that is powered by electricity'
Last Updated: Jun 30, 2023

Setting up Express.js

gp-icon
Basics of javascript
Free guided path
10 chapters
68+ problems
gp-badge
Earn badges and level up

Introduction:

Previously, we have already covered what exactly node.js is and the reason for which we need them. We have also learned how it came into existence. In this article, hoping that you have already installed node.js, we will create a directory for holding the application and make that a working directory. Exciting, right!!? So without wasting any time, let’s get started. 


Happy So Excited GIF 

Source: Giphy

 

Getting started:

$ mkdir myapp
$ cd myapp

 

In the next step, we need to use the package.json package file for the application. If you need more information about the working of package.json, you can visit here.

$ npm init

 

This command gives rise to several things, like the name and version of the application. For the time being, we can use now RETURN to accept defaults for most of them, with the following exception:

entry point: (index.js)

 

Choose and enter the name of the main file. You can even name it app.js. But, if you need the previous name index.js, just click on return to backtrack to the default value.

In the following steps, we need to install the Express in the myapp directory and save it for the dependencies list.

$ npm install express --save

 

For installing Express temporarily, for the time being, we can also use:

$ npm install express --no-save

 

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

FAQs

  1. Mention the steps to execute Express.js in the terminal?
    The steps to execute Express.js in the terminal are:
    For checking if the node is already installed: node -v
    For checking if npm is already installed: npm -v
    We need to set up the project: mkdir express-tutorial && cd $_
    For getting started, change it to a folder.
     
  2. Can node JS die?
    No, the node JS can never die even if the type has stabilized a little over the years. As it’s working beyond 2021, it’s still the same and will keep working as it is.
     
  3. Why is Express JS preferred over Node js for server-side development?
    Express JS is also a node js framework with many more advantages and specifications that help run server-side applications much faster and smartly. Hence, it is more preferred.

Key Takeaways

In this article, we have how to set up and start working with Express JS. Further, we have covered some frequently asked questions, which generally come to mind when learning Express. 

Keeping the theoretical knowledge at our fingertips helps us get about half the work done. To gain complete understanding, practice is a must. To achieve thorough knowledge, visit our page.

Recommended Readings:

NPX vs NPM

Previous article
Introduction to Express
Next article
Authentication and Authorization in Express
Guided path
Free
gridgp-icon
Basics of javascript
10 chapters
68+ Problems
gp-badge
Earn badges and level up
Live masterclass