Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialIkuyasu Usui
36 PointsSo, express is a server program? Node is not a server?
I thought Node.js is a sever program and express helps us operate it with ease.
1 Answer
Alexander La Bianca
15,959 PointsNode.js is a javascript run-time environment for executing javascript on the server side. The code runs on the server. Express on the other hand is a very popular web framework for node applications. It let's you easily set up a node server and creating routing for your website and or API. Node can do that without Express, however it involves more code. Node can also be used for other things though like creating command line applications that you can simply execute on your command line. For example: I had the need to create a program to convert a given xml file into a json file with a particular json structure. I wrote the program in javascript (using node). I can then execute the program in my command line whenever I want.
Ikuyasu Usui
36 PointsIkuyasu Usui
36 PointsThank you. I thought it would be something like that. I had just hard time convincing myself to describe the particular essentialness of Express.js. Because you never learn how to do routings only using Node.js (I believe), it is hard to know the usefulness of Express. So, you are saying that Node.js only can handle various routings?
Alexander La Bianca
15,959 PointsAlexander La Bianca
15,959 PointsNode.js can handle all routings. Under the hood Express.js uses Node.js. So in reality Node.js is doing all the routing and setting up the server. Express is just the framework. The Express framework provides us with methods and classes to make the process of setting up a webserver much easier. In Express:
That is super simple in express right? This is a get request to our /home route and we respond with "Hello World". Yet when pure Node.js is used, you at first needs to find out what type of request is coming in and do other stuff.
I believe the Node.js basics course takes you through setting up a small app by using pure Node.js. You will see that it is quite repetetive and more convoluted.