HomeBack-End & DatabaseGetting Started With Express 4.x – Tutorial 1

Getting Started With Express 4.x – Tutorial 1

In this blog post, we will see how to start with expressjs and create your first hello world application

Express is a minimalist frontend framework of nodejs. This framework can be used to create fast and robust apis, mobile app backends, small websites, and many more things. We will straight away get into how to create your first application. This blogs assumes you already have a background knowledge of working with nodejs.

To install express simple run
[code]
$ npm install express
[/code]
*assuming you have nodejs installed already this will install express

Getting Started

Fastest way to get started with express is to use express-generator. It creates a directory structure and pre-defined files which help you to get started with express.

To install express generator use
[code]
$ npm install express-generator
[/code]
Lets name our project “helloworld”, so to create an express project. Simply run

[code]
express helloworld
[/code]

It will create various directories and files for your application.
Next we need to install dependencies relating to the project
[code]
cd helloworld
npm install
[/code]
now finally to run your application do
[code]
set DEBUG=helloworld & node ./bin/www
[/code]

On ubuntu/linux you don’t get the bin/www folder then follow this process to install

[code]
$ npm -g install express
$ npm -g install express-generator
[/code]
And if you get errors like ‘debug’ module not found, then run npm install for each module

[code]
npm install debug
[/code]

Now in your browser if you open http://127.0.0.1:3000 you see your first express app.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: