Here we go with Javascript Again 😕

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.

NodeJS Homepage

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:

My NodeJS version Number

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.


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:

  1. 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.
  2. Open express-practice project folder in your Favorite Text Editor, in my case Atom.
  3. Create a new file named index.js
  4. 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!');
I just Felt Like Bragging about Atom 😜

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:

Result from step 7

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

The Express App Runs Successfully 😋

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 🚶🏽