NodeJS Tutorial
NodeJS Tutorial
js Introduction
❮ PreviousNext ❯
What is Node.js?
Node.js is an open source server environment
Node.js is free
Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
Node.js uses JavaScript on the server
Why Node.js?
Node.js uses asynchronous programming!
A common task for a web server can be to open a file on the server and return
the content to the client.
Node.js eliminates the waiting, and simply continues with the next request.
Download Node.js
The official Node.js website has installation instructions for
Node.js: https://nodejs.org
Getting Started
Once you have downloaded and installed Node.js on your computer, let's try to
display "Hello World" in a web browser.
Create a Node.js file named "myfirst.js", and add the following code:
myfirst.js
The code tells the computer to write "Hello World!" if anyone (e.g. a web
browser) tries to access your computer on port 8080.
For now, you do not have to understand the code. It will be explained later.
How to open the command line interface on your computer depends on the
operating system. For Windows users, press the start button and look for
"Command Prompt", or simply write "cmd" in the search field.
Navigate to the folder that contains the file "myfirst.js", the command line
interface window should look something like this:
C:\Users\Your Name>_
Initiate "myfirst.js":
If anyone tries to access your computer on port 8080, they will get a "Hello
World!" message in return!