nodejs-intallable

Install nodejs and npm on windows

Node.js is an immensely popular JavaScript runtime. It is open source, cross platform, asynchronous and event driven. Typically, we know that that JavaScript runs on the browser. But with Node.js, we run JavaScript in server environment. On the other hand, npm is an online repository for hosting and publishing open source nodejs project. Npm also provides a CLI (command line interface) tool to interact with this npm repository for dependency management, package installation etc. In this tutorial, we will see how to install nodejs and npm in windows. We’ll also write a hello world example using nodejs.

How to install Node.js and npm on Windows

Let’s get started and learn how to install nodejs and npm on Windows.

  1. Download the installable

    Head to nodejs installable download page. Click on the highlighted Windows Installer icon. It’ll download the latest available installer .exe file.nodejs-intallable

  2. Install nodejs

    Double click on the downloaded windows installer .msi package and launch the wizard. It is very simple wizard. Just click on next, accept the license agreement after reading through it, choose the location of installation and then select what you want to install and want to exclude from installation. I have kept everything default without any change whatsoever. Then finally at the end of the wizard, click on install button. It’ll take couple of minutes to complete the installation. That’s it we are done with the process. It is as simple as that.

  3. Check the node and npm versions

    Now, launch a command prompt and provide following 2 commands (node -v and npm -v)to check the versions of just installed nodejs abd npm. A successful result of these commands will also tell us that installation is successful.
    nodejs-version

Write a Hello World Application using nodejs

We’ll now write a very simple script that will create a web server and when executed, render Hello World! message.

  • Copy the below piece of code and save in a file with name helloworld.js in any folder of your choice.
  • Open a command prompt, traverse to the folder and issue the command node helloworld.js
  • Then, open a browser and hit http://localhost:8080. You will see something like below:
  • You can press Ctrl + C to stop the server.

Conclusion

Great!! So, you just learned how to install nodejs and also learnt to write your first Hello World! app in using nodejs.

125

No Responses

Write a response

This site uses Akismet to reduce spam. Learn how your comment data is processed.