In the last two articles we introduced you to Node.JS. We covered what Node.js is and what are some of its major features. In this article, we are going to study the node.js environment setup process. Though, you can run your code online as well, but if you are looking for some serious node.js development, you must set up a local environment.
To write and execute a node.js application on your local machine, you need a couple of software: A text editor and binary installables of node.js. You can use any text editor. I recommend using Notepad++ or Brackets. They are totally free.
You simply have to type the Node.js code in a text file and save it with “.js” extension. Now in order to execute this code, you need node.js binary installables. The process of downloading and installing these libraries has been explained in the next section.
Go to this Download link and download the corresponding download file depending upon your operating system. I shall explain the download and installation process for windows. For windows OS, download the “.msi” window installer. Follow the installation process. By default, node.js will be installed in the “C:\Program Files\nodejs\” directory. Also, the installer will set the enviroment’s path varianble to C:\Program Files\nodejs\bin
Now in order to see if node.js has been correctly installed and is working without an error, create a text file named myapp.js and add the following code to the file “console.log(“Welcome to Knowledge Hills.”)”. Now open the command prompt and type “node myapp.js”. You should see “Welcome to Knowledge Hills.” printed in the command window if everything goes fine. Please mention full path to the “myapp.js” file after you type node command in the prompt window. If command prompt throws an error or it doesn’t display the message “Welcome to Knowledge Hills.” on the command prompt, your installation wasn’t successful. In that case, I would advise you to repeat the process.
In this article we discussed how accomplish node.js environment setup. In the next article we shall create our first node.js application. So keep visiting this site and Happy Coding!!!