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 trialmatthewshear
9,229 PointsI've gone as far as making a Node.js server and I still have no idea why I would ever need to use Node. EVER.
Everything Node.js does can be done on the client side. Why would I want to use Node.js?
Also, I've watched the course on building a basic node.js server and it makes no sense at all to me. This topic seems totally pointless. So confused.
5 Answers
andren
28,558 PointsWhile it's true that a lot of things these days be done client-side, one thing you have to realize is that client side code can be seen and modified by any client using your site.
Let's say you wanted to read some information out of a database and format your HTML based on that (this is an extremely common thing in real-life websites) to do that you would need to have the username and password of your database present in your code. Do you think sending code which contains sensitive information like that directly to a client which can easily look at the code you send them is a good idea?
Let's say you were designing a website with a login system. Any code you write to validate that the user provided the right password to login would be modifiable by the client, in such a way that they could in fact make the code accept any password for any user. Completely bypassing the password authentication system you built into your website.
Those are just two examples of things that can't securely be done with client-side code, there are numerous other tasks like that but I think you get the gist.
The point of writing and having code executed on a server is that the code never leaves the server, only the result of the code does. This means that you have complete control over the code. Only people with control over the server can modify and look at the code.
Node.js allows you to use JavaScript as a server-side language, but you don't have to use Node.js and JavaScript on the server. You could use PHP, Ruby, Python, Java, C#, etc but ultimately in any real-world website you will end up needing some kind of server side code. There is just no way around that if you intend for your site to perform some function that needs to be secure and reliable.
Bryn Price
Full Stack JavaScript Techdegree Student 7,253 PointsWhilst I have not reached the Node.js part of my studies yet, but I know once you start getting onto the server side of things it can get more confusing. I did learn some of the Ruby On Rails basics to help get me into understanding the server side of things (and I need it for my website), as it is one of the less complicated frameworks to get started with, because it does a portion of the work for you, in that it favours convention over configuration (so it just assumes a number of things instead of saying "come configure this for me"). I don't know if it's worth looking up tutorials to help get your head around something like Ruby On Rails? Or PHP or something similar. If the concept of server side programming is not getting in. Though sometimes worth pursuing to see if you do get that "ahah" moment where the rest makes sense.
As pointed out, doing things on the client side can be so much of a risk of security. I tend to do things both on the client and on the server side. On the client, so users get a fluid experience of the site, for example, if "admins" are the only ones able to post articles on my site, they won't see any option to do it if they're not one, but at the same time, the server still says "no" if somebody figures out a way around that. For a number of people out there, it's not too difficult of an attack on a website and when the server tells them to go away, it's much harder. Same reason you hash your passwords, people will try and pull a lot to break through your security.
Fortunately, Node,js is just one of many choices, so you can end up choosing what works best for you. But still worth knowing as it is sometimes used with other frameworks.
Dane Parchment
Treehouse Moderator 11,077 PointsNode.Js is extremely important in the current web architecture. It allows among other things for JavaScript to act as the back-end for a website, something you would have to do with a language like PHP, Ruby On Rails, Python, etc.
Now with Node.Js we have a much more versatile way of handling and creating web applications using a single language: JavaScript.
Node.Js has also paved the way for many new frameworks (Angular, React, etc. ) and allows better sharing and installation of those frameworks (among others) with the node js package manager.
Here I advise you to read these articles:
https://dzone.com/articles/what-nodejs-and-why-should-i https://www.linkedin.com/pulse/why-nodejs-more-important-than-you-think-nexus-software-systems https://www.quora.com/What-are-the-benefits-of-Node-js
Ryan Zimmerman
3,854 PointsBecause in the real world we render on the server side by bundling multiple libraries together and then push it all to the client. It helps to understand how a server works and an api is structured. Plus it will help you make more money.
matthewshear
9,229 PointsThat's all useful information but I cannot proceed because of this issue, which nobody will respond to. I cannot proceed until this is dealt with. I didn't write this one, but I'm having the same problem:
https://teamtreehouse.com/community/nodejs-workspace-not-working
PLEASE someone make the workspace for this course work again! https://teamtreehouse.com/library/build-a-simple-dynamic-site-with-nodejs
When I try to preview the workspace, I get a page that says "Workspace Unavailable This is a preview link for a Treehouse Workspace that is not currently active. If you are the workspace owner, you can launch it again via the Treehouse site."
Here is what it looks like: https://drive.google.com/open?id=0B9ENONF87ob1bUhCS2MyaHdMUGM