How to NodeJS- Express App directory structure

In this tutorial, we are going to learn Node.js Express app directory structure. The express app has set up with a good organized files and folders structure. The following tree diagram shows the directory structure of the Node.js Express app.


Node.js Express App directory structure

Express app directory structure


Express App directory tree:
App Directory Structure
  ├── bin
  |   └── www
  ├── node_modules
  ├── public  //contains your static files that are not handled by any compilers
  |   ├── images
  |   ├── javascripts
  |   └── style sheets
  ├── routes
  |   ├── index.js
  |   └── users.js
  ├── views
  |   ├── error.jade
  |   ├── index.jade 
  |   └── layout.jade
  ├── app.js
  ├── package.json



The folder bin is short for binary. It generally refers to the built applications that do something for a specific system. It contains a single file named www.js


www.js is the core file of express app project which creates an HTTP Server and passes app as the handler. In this file, we can configure the listening port for HTTP requests using server.listen(port_number). Port 3000 is the default port used in this file.  It also performs error handling while starting the server.

It also performs error handling while starting the server.

This file is the configuration for creating and run the Node.js server. so it is responsible for our project up and running.



Node_modules are the addition modules in addition to core modules. All of the core modules are loading from external libraries. You can any node_modules to the library using package.json. We will discuss it in coming tutorials.



It will contain all the assets needed for your app that is not related your NodeJS code. This folder includes files and folders that can access users public. it includes images, javascript and CSS files etc. A helper function that simply returns the full path to this depending on setup.


This folder includes all the images and icons to display on the website. Users can access the web pages


 This folder includes all the javascript files used by the website. JavaScript files are written for your app that is not for Node.js

style sheets

It includes all styles and style related files (SCSS or LESS files).



Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method.

The routes directory contains all of the route definitions for your application. By default, two route files are included with the express app: index.js and users.js.


This file is responsible for pages on websites. As the default, a router to the home page already exists.


User.js is responsible for handling user requests to user pages of the website. As the default, when a user request /users route, app.js handle the request with user.js and respond with the resource.


This is responsible for displaying all or a portion of the data to the user. Jade is an HTML templating engine. All jade files need to be transformed into the HTML.


It responsible for displaying error messages like page not found 404.


Index.jade file include HTML tags and texts to display on home page.


Layout.jade is responsible to extends common page template to unique contents.



App.js id the core foundation of the Node.js project. so essentially whenever a user comes to our website and makes a request. app.js is going to look at the request and it figures out how to handle the response depending on URL.



The package.json is present in the root directory of any Node application/module and is used to define the properties of a package. The package.json file main purpose is to remember your application dependencies and their respective versions.

Anwar Yakkiparamban

Anwar Yakkiparamban is the founder of Lauyou Learning. Prior to Lauyou learning, Anwar worked at ARD Engineering & Development, Qatar. He holds bachelor degree in Electronics and Communication Engineering from Govt. Engineering College Idukki.

You may also like...