In this post we will take a step by step look in setting up Express and creating first application. I assume that you have already installed Node. If not then go ahead and install from here
Once node.js is successfully installed, you can install Express framework by running npm install express on command prompt.
After installing express, I will recommend to create a new folder and change directory to newly created folder. I have created a folder expressjs and going to create a site named mysite using express framework. To create site run command express mysite . mysite is name of the site.
On successful execution of above command you will get suggestion as below that several files has been created.
Next to install dependency. To install that navigate to site directory. You can navigate to site directory using cd mysite. In mysite directory
It will install all dependency in mysite directory.
After successful installation of dependency you should get npm info ok message as shown in above figure. Now you can run created website by express using node.
In browser navigate to server on port 3000 and you will get basic site created using express up and running.
This is how you can set up express to create sites running on node.js. In further posts we will look into routing, app.js, routing path, http verbs. I hope you like this post. Thanks for reading.
Leave a Reply