How To Install And Test Node.js Environment On Windows 10 Professional

in #utopian-io8 years ago (edited)

Welcome to a brief tutorial on how to enable your Windows 10 Professional machine to run Node.js scripts.

What Will You Learn?

By following this tutorial you will learn how to install and use Node.js on Windows. We will enable pure Windows machine without any additional packages to use all the benefits and functionalities that Node.js brings to the development of JavaScript applications.

By the way, Node.js is an asynchronous event driven JavaScript runtime and is designed to build scalable network applications.

Requirements

The requirements that will enable you to follow and fulfill this tutorial are:

  • MS Windows 10 Professional environment
  • a download of Node.js installer package (at the time of writing this article it is LTS Version: 8.11.1 which includes npm 5.6.0)
  • a bit of your time, less than 15 minutes

Difficulty

  • Basic, it really is elementary

Let us start, shall we?


1. Downoal Node.js installer

Go to Node.js downloads page and download the latest installer package. For the purpose of this tutorial we will download 64-bit Windows Installer (.msi). The file's name is node-v8.11.1-x64.msi.

image.png


2. Run Node.js installer and install it

After the download finishes you can run the installer straight from the browser. The default install location is C:\Program Files\nodejs\. We will leave this option unchanged. We will also leave unchanged everything in the Custom Setup screen.

This means that the executables for Node.js and npm will be added to the default Windows search path.

image.png

The install starts. It requires Administrator rights which we will confirm.

After several seconds Node.js setup is complete.

image.png


3. First Test Of Node.js In Action

Let's open up a command window and type:

node -v

The results should be the following:

image.png

Congratulations. Node.js is running on your Windows machine.

Let us also check the help option:

node -h

image.png


4. Obligatory Hello World Script As A Server

Our final step of this tutorial will be a script which will act as a simple http server.

Copy the following script in the text editor of your choice and save it, let's say, in the c:\temp directory. You can also check it out from my github repository.

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello Utopian.io\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

Open a command prompt window and position yourself in the C:\temp directory - or whatever directory you've saved the script in.

cd \temp

Run the script with the help of Node.js runtime.

node hello_utopian-io.js

Your first server starts ...

image.png

Is it really working? Open your favorite browser and enter the following URL location.

http://127.0.0.1:3000

image.png

Tada :) Congratulations! Your first Node.js is very much alive and working, thank you.


Conclusion

You've learned how to install Node.js on Windows and how to run your first script. This is just the beginning of your journey to a fully developed and modern web application.

In the tutorials to come I will show you how to use Node.js packages to add functionality and how to build applications. For example, Steem blockchain frontend. Or Ethereum blockchain client. Or ... sky is the limit!



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • Your contribution on how to Install And Test Node.js is basic and not technical for approval on utopian .

You can contact us on Discord.
[utopian-moderator]

@rufans
Well, the decision is yours to make, thank you.

Yes, it is basic.

Are you saying that utopian.io accepts advanced tutorials only? So, where do people go to when they need to learn something new?

The tutorial category is for unique contributions (installation tutorials are generally already covered extensively elsewhere) that are technical instructions, which use text and graphics to clearly explain and teach significant aspects of an open-source project

OK, thank you for your explanation.

Hey @rufans, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

I have the suspicious I'm going to learn a lot from these posts ;-)

:) Me too. It is just a start to a loooong series. I intend to document as I go. The final goal is a fully functional javascript client for any blockchain platform.

The intermediate goals are creating a client for Steem mainnet and EOS, Ethereum and RChain testnets.

Yes, there are ambitious goals indeed :)

Thank you for this. Looks easy. I save this post, I'll try to do something :) btw: is the same procedure for win7? I have one laptop with win10 but my productional machine runs win7...

Thanks. Yes, it should be the same.

se se niti nisem odlocil za w 10 razlogi so naplosno znani ;)vohu jenje keyloger ;)

Mah, ne vem. Vdori so možni povsod. Kot OS je desetka čisto spodobna zadeva. Se M$ uči na svojih napakah :)

This is very fun reading this particular blog post as a node.js devloper,btw great work.

You are a node.js developer? That's great to hear. Then you can teach me :)

I did some javascript years ago when there were no libraries and frameworks. In fact, my biggest web app was php + mysql + pure javascript. Quite a lot of work :)

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.100
BTC 64712.56
ETH 1875.41
USDT 1.00
SBD 0.38