Tutorial 3 NodeJS-Project Structure

In the previous post, we have learned how to create a simple Node project with the help of Eclipse IDE. The project structure created was a bare project with no folder structure. I went through many online posts, tutorials and the suggested folder structure was as shown below. This is a widely accepted project structure for Express projects.Now what is Express ? Express is, “Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications…”. I am not going to cover Express because internet is full of articles regarding this. Now lets see the folder structure of an Express project,


A small description for each folder. We are trying to achieve the MVC design pattern and with that motive the three folders (controllers,models,routers) under the directory app are depicted. All static items (html,css,java scripts) will go under the public directory.  Well, it could be any directory depending on your choice and configuration. That’s it.

Now lets look at the project.json file.

projectjsonIn the part, “dependencies”, all required dependencies are added. We have put some dependencies as shown in the figure namely (express,connect, ejs, mysql, body-parser etc).Now how to download the dependencies ?

Lets navigate to the root folder of the project.Just right click on the project and select Properties,


Copy the Location and open a command prompt and navigate to that location.


And now it’s the time to execute the npm install command. It will download all the necessary dependencies defined in the project.json. Now if you refresh the project in the Eclipse IDE, you should see all the libraries downloaded.See the figure here,


And you are done. Your project structure is complete and now ready to code. In the next post, we will see how to organize the codes to meet the MVC pattern.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s