Google News
logo
Express.js - Interview Questions
What do you understand by Scaffolding in Express.js?
Scaffolding is a technique used for creating the skeleton structure of an application. It facilitates users to easily create their public directories, routes, views, etc., or a web application skeleton. Generally, users manually create their public directory, add middleware, create separate route files, etc. Using a scaffolding tool, they can set up all these things to directly get started with building their application.
 
There are two ways to install Scaffolding and use it in your application.
 
* Express application generator
* Yeoman

Express application generator : This is used to create an application skeleton quickly. Use the following command to install the Express application generator.
npm install express-generator -g  
express myApp  
By using the above command, a project named "myApp" will be created along with following the files/folders in the project.
 
Bin : The bin folder contains one file called www is the main configuration file of the app.
Public : The public folder contains JavaScript, CSS, and images, etc.
Routes : This folder contains the routing files.
Views : The view folder contains the view files of the application.
js : The app.js file is the main file of the application.
json : The package.json file is the manifest file. It contains all metadata of the project, such as the packages used in the app (called dependencies) etc.
 
Now, we have to install all the dependencies mentioned in the package.json file by using the following command :
cd myApp  
npm install
Yeoman : Use the following command in your terminal to install Yeoman :
npm install -g yeoman  
Yeoman uses generators to scaffold out applications.
Advertisement