Installing ExpressJs

Previous: What is Express

The first step is installing Express onto your system. For this, you will need NodeJs. Go for the LTS version as using a stable one is best for projects. Once done open your terminal and check if it's installed properly by running

node --version and npm --version

Both commands should give a version number in return. npm (node package manager) is used to install packages (helper functions) that will take care of a lot of common tasks so that you don’t have to reinvent everything.

Open up your terminal and create a new folder and jump into it using your IDE. I usually use VSCode as it comes with a bunch of extensions that make the coding experience beautiful.

Once inside your folder, you will need to initialize your project using

npm init

This is so that you get a package.json file. This is the manifest file or a file that gives basic information about your project. You will need this file to install express or any other packages you will use in your project. We call them dependencies.

Now we can install express using

npm install express

If you open the package.json file, you will see express listed under the dependencies object like so.

You can see a version of express installed too next to it. Dependencies basically mean what is required to run your project. So tomorrow if you are sharing your project with someone else, he will have to install everything you have installed to get it running. And hence this file gives a list of what all things are needed.

Great now that things are installed let us start creating our endpoints.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store