Hello folks! Welcome back to a new section of our tutorial on ExpressJS. In this tutorial guide, we will be studying about ExpressJS Scaffolding.
Scaffolding lets us to conveniently create a skeleton for a web application. We manually create our public directory, add middleware, create distinct route files, etc. A scaffolding tool performs all these things for us so that we can directly get started with building our application.
The scaffolder we will use in this tutorial is called Yeoman. It is a scaffolding tool that is built for Node.js framework but also has generators for several other framewoks (like Flask, rails, Django, etc.). To install Yeoman, simply input the following command in your terminal -
Scaffolding lets us to conveniently create a skeleton for a web application. We manually create our public directory, add middleware, create distinct route files, etc. A scaffolding tool performs all these things for us so that we can directly get started with building our application.
The scaffolder we will use in this tutorial is called Yeoman. It is a scaffolding tool that is built for Node.js framework but also has generators for several other framewoks (like Flask, rails, Django, etc.). To install Yeoman, simply input the following command in your terminal -
npm install -g yeoman
Yeoman utilizes generators to scaffold out applications. To check out all the generators available on npm to utilize with Yeoman, you can click on this link. In this tutorial, we'll use the 'generator-Express-simple'. To install this generator, input the following command in your terminal -
npm install -g generator-express-simple
To utilize this generator, enter the following command -
yo express-simple test-app
You'll be asked a few simple questions such as what stuffs you intend to use with your app. Select the following answers, or if you already have a proper understanding about these technologies then start choosing how you want them to be.
express-simple comes with bootstrap and jquery [?] Select the express version you want: 4.x [?] Do you want an mvc express app: Yes [?] Select the css preprocessor you would like to use: sass [?] Select view engine you would like to use: jade [?] Select the build tool you want to use for this project: gulp [?] Select the build tool you want to use for this project: gulp [?] Select the language you want to use for the build tool: javascript create public/sass/styles.scss create public/js/main.js create views/layout.jade create views/index.jade create views/404.jade create app.js create config.js create routes/index.js create package.json create bower.json identical .bowerrc identical .editorconfig identical .gitignore identical .jshintrc create gulpfile.js I'm all done. Running bower install & npm install for you to install the required dependencies. If this fails, try running the command yourself.
It will then create a new application for you, install all the dependencies, add few pages to your application(home page, about page, contact page, 404 not found page, etc.) and gives you a directory structure to work on.
This generator creates a very easy structure for us. Explore the several generators that are available for Express and select the one that fits you right. The steps to working with all generators are the same. You will need to install a generator, run it using Yeoman; it is going to ask you some questions and finally create a skeleton for your application based on your answers.
This generator creates a very easy structure for us. Explore the several generators that are available for Express and select the one that fits you right. The steps to working with all generators are the same. You will need to install a generator, run it using Yeoman; it is going to ask you some questions and finally create a skeleton for your application based on your answers.
Alright guys! This is where we are going to be rounding up for this tutorial. In our next tutorial guide, we are going to be discussing about ExpressJS Error Handling.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.