
Getting Started with ExpressJS
Hi There,
This is my very first article, I am a core PHP developer trying ExpressJS for the very first time, after hating on Javascript at the Backend I’m willing to give it a try.
Step 1: Install NodeJS 🤗
You can get the Latest version of NodeJS from here [The Official NodeJS website] follow the instructions and you’re Good to go.

To confirm you have NodeJS installed open Terminal or Command Prompt (for our Windows Brethren) and run:
node -v
you should get the version number of your NodeJS installation, in my case:

Step 2: Install ExpressJS
After Successfully installing NodeJS you can proceed with installing ExpressJS.
Start by:
- Opening Terminal, this should open your home directory if you’re on Mac
- Change directory to your Documents Folder by typing
cd documents
- Create a new folder by typing
mkdir express-practice
you can name the folder whatever you want but in this case I’m sticking with this.
then..
Change Directory to the newly created folder by typing
cd express-practice
- now run
npm install express --save
This would install Express in the express-practice
directory and save it in the dependencies list
Step 3: Getting it to Run in the Browser
Now you need your ExpressJS Application to run in the Browser, you can achieve this by following these steps:
- run
npm init
, This command prompts you for a number of things, such as the name and version of your application. For now, you can simply hit RETURN/ENTER to accept the defaults for all of them. - Open
express-practice
project folder in your Favorite Text Editor, in my case Atom. - Create a new file named
index.js
- put the code below in that file
var express = require('express');
var app = express();app.get('/', function (req, res) {
res.send('Hello World!');
});app.listen(4000, function () {
console.log('Example app listening on port 4000!');
})

5. Save the file
6. Now go to Terminal, make sure you’re in the express-practice
folder directory
7. Run node index.js
You should see this:

8. Now open http://localhost:4000 on your browser you should see this:

At this point you have successfully set up your first ExpressJS Application
Thank you for Reading to this point, i hope to publish more on ExpressJS as i progress with it, till then i can be found in front of my laptop and on Twitter.
For Now I’m going back to PHP and Laravel 🚶🏽
Bye