Introduction to Node.js
Why should I use Node.js?
There are many server-side languages and frameworks that you could use for your project, but if you want to keep the frontend and backend in the same, easy to use language then it’s definitely worth looking into. It’s also very quick to setup a project with lots of advanced features that could take you a while with other basic tools.
How do I install Node.js?
Node.js can be installed on most operating systems with ease. You can download for Windows here.
sudo apt-get install nodejs
brew install node
You can find a detailed installation guide via the Node.js website.
How do I run Node.js?
It’s as simple as running the command
Here’s an example of it in action if you’re still unsure. Let’s call this file
var message = 'Hello World!';
This should be self explanatory — this will output the message to the console. In the browser this would show in the developer tools section as a message that would be pretty helpful for debugging, but in Node.js this would actually output to the command line instead. You can execute this in Node by running
node helloworld in the directory you are in. This should output
Hello World! as expected.