Installation of Node.js
It is very easy to install node.js in any OS you are using and the most interesting part is that installing node on ubuntu is much easier!!!!
You can run node in any of your preferred OS but I recommend to work with node on ubuntu or on linux rather than WINDOWS. Because, there is some module for example bcrypt.js(most famous modules used in node and its framework) that you face problems with while installing these modules. But, don’t worry you can still use windows to run node js.
Installing node on windows
- Go to https://nodejs.org/en/download/ the official website for node js.
- There you find your installation files according to your PC’s environment.
- Download window installer (.msi) file or window binary(.exe) file in respect to your OS i.e 32-bit or 64bit
- Now just install it by clicking next,next………,finish as like installing typical software on windows.
- You are done.Really, you installed Node.js
Setting the installed node.js path as global:(windows 10 and 8)
In windows, we need to set the node.js path so that we can use node command elsewhere .Given bellow is the way to set the node js path(same as you set for php or java)
- In Search, search for and then select: System (Control Panel)
- Click the Advanced system settings link.
- Click Environment Variables. In the section System Variables, find the
PATHenvironment variable and select it. Click Edit. If the
PATHenvironment variable does not exist, click
- In the Edit System Variable (or New System Variable) window, specify the value of the
PATHenvironment variable.It is the path of your installed node.exe; it may be somewhere in your C:\ drive
- Click OK. Close all remaining windows by clicking OK.
For being sure it is installed or not just open your cmd and write node and press enter. If is shows many options then it is ok otherwise check again.
Note: Restarting your machine after installing node js is a MUST.
Installing node js on ubuntu using maintained ubuntu package manager:
As I said, It is quite simple:
- Add the Node.js-maintained repositories to your Ubuntu package source list with this command:
curl –sL https://deb.nodesource.com/setup | sudo bash –
- Now write the following command:
sudo apt-get install nodejs
- That’s it node installed but one more thing to install. And, it is npm that I talked a bit about in my last post. NPM is node package manager . I will describe it later when we will use it. Let’s go to see how to install npm:
- Now you can test it using the following command given on the snapshot: node -v (to get the version of your node.js)
- Ok now let’s start node.js operations on command line.All commands same for any OS These are just for the warm up up with node. In the next part, I will show you how to create node server and run a program