Getting started with ExpressJS
Chapters
This course is for beginners who wants to get started with ExpressJS framework for NodeJS. This course is subdivided into 13 parts as listed below
- Welcome note
- Installing NodeJS and ExpressJS
- Developing your first application with ExpressJS
- Working with Views/Templates
- Handling requests
- Application specific settings
- Midlleware and request flow
- Understanding routes
- Modularizing routes in ExpressJS
- Request Object
- Response Object
- A word on locals
- Conclusion
Please let us know how we can do better next time by leaving your feedback.
Author: Subject Coach
Added on: 5th Mar 2015
Please get in touch with your teacher or tutor in case you have a question related to this lesson
None just yet!
To install expressJS, we will first need node to be available on our system. You can get node by browsing to nodeJS.org.
When you click on the downloads link from the top navigation bar, you’ll see that there are three options for different operating systems. First one is Windows installer, second is Mac package, and third is if you want to install nodejs from source code.
I’m using centOS to install node on. We will use the source code option to install nodeJS. Although they are few options to install node, the first one is by using NVM, the node version manager and second is through epel, and third one of course using the source code. I’ll grab the link to source code archive, by right clicking on the link and selecting copy Link location. Now I will launch a terminal session with my remote centOS machine. I will now change my working directory to OPT.
I will now download the source code archive using wget tool. Once the file is downloaded, I will then extract it and change my working directory to the extracted archive folder. I can now verify my current working directory using the PWD command.
Before I do anything else, I need to install GCC and C++ compilers. I will use the Yum to do that. I already have those packages installed on my system, I can now just type ./configure and press enter.
next I will execute the make script. Once make finished doing its thing, I am ready to install node by typing, make install. Once I do that I have node available as a command. To verify that I will type ,
node ––version
This will output my current node version.
Node comes with the NPM, NPM is node package manager. We will use NPM to install express. Goto expressJS.com to read the getting started guides and other stuff such as API references. Express can be installed either globally, or you can install it under current working directory. To install express globally type in,
NPM install –g express.
Now let’s see how I can install express locally to a folder. I will create a directory called express, and change my working directory to express, and then install express locally to this folder by removing the –G switch from the previous command.
So you see it’s easy to install express and node. Based on your operating system you can grab the relevant installer files to install node, and then use NPM to install express.
In the next chapter we will look at how to write our first express application.