Tech Junkie Blog - Real World Tutorials, Happy Coding!: Node.js : Setting Up Node.js "Hello World" Node.js

Thursday, April 9, 2015

Node.js : Setting Up Node.js "Hello World" Node.js

So according to Node.js's official website http://www.nodejs.org, NodeJs is

“a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”

So what does that mean in English?  Well it basically means that Node.js enables developers to use JavaScript like it's a server.  Allowing you to do JavaScript server-side like development without the backend servers.  Under the hood of Node.js is the virtual machine call V8.  If you need something lightweight Node.js should be able to fit the bill especially on the client side.

Here are the steps to step up Node:

1.  Go to the website https://nodejs.org/
2.  Click on the "Downloads" tab
3.  Download the install file for the your system




































4.  Double click on the .msi file you've just downloaded







5. Click "Next" on the welcome screen

























6. Check "I accept the terms in the License Agreement, then click  "Next"
























7.  Accept default and, click "Next"
























8.  Accept the default destination, and click "Next"
























9. Accept the default on the "Custom Setup" screen, then click "Next"
























10.  Click the "Install" button on the "Ready to install Node.js"























11.  The installation will start automatically.


 12.  Click "Finish"


 13.  Now that Node.js is installed, we have to test it to make sure that it works.

14.  Create a file call "HelloWorld.js" with the following code

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World http\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

15.  Open the Microsoft Command Line Prompt console and type in the following code, you have to navigate to where the "HelloWorld.js" file resides first before you run the command

Node HelloWorld.js








16. You might be wondering what happened to the text you wrote in the HelloWorld.js file "Hello World http", well that's the magic of Node.js.  If you type the URL http://127.0.0.1:1337 into your browser you will see that the text is displayed on the browser.  Node.js is basically hosting your JavaScript listening on port 1337.  Very cool indeed.









6 comments:

  1. Below are the 15 best Minecraft mods everyone should try. Optifine. No matter if it's your first time playing Minecraft or you've been playing it for a long time now. 9minecraft mods

    ReplyDelete
  2. Epson is a famous brand producing different printers from Inkjet to LaserJet with various shapes, sizes, designs, and so forth It is reasonable for home and office also to finish individual and expert printing errands. Epson printer is been the best option of gigantic individuals all around the the globe because of its extraordinary highlights and very much worked during the printing process. Fix epson printer not printing issue

    ReplyDelete
  3. https://assamjobclub.com/

    ReplyDelete
  4. Всем привет, хотел бы спросить не много не по теме, кто нибудь смотрел фильм Солнечное побережье?Стоит ли его смотреть? Слышала он вышел в 2024 году и не плохой фильм.

    ReplyDelete

Search This Blog