Hello, friends how are you today !!! so today I just thought that there should be something other than hacking so this article is for all those programming lovers and also you can use this tutorial to setup your own API testing server. In this articles, I am going to teach you how to setup/install node.js on your Local Windows or Linux Machine.
What is Node.js?
Mostly is being used to develop API’s for applications and it is a server-side platform, Node.js is an open source, a cross-platform runtime environment for developing server-side and network applications.
What should you know before getting into it?
You should know that Node is not an application that you can pin into the taskbar and use it like MS Word or Photoshop. It is a command line application and you should know the basics to use Command line.
Setup Node js Server local Windows / Linux machine:-
Installation on Windows:-
Installing Node.js on windows is pretty straightforward as Node.js provides an installer for windows on their website.
- Download the windows installer from the Node.js website.
- Run the installer (the .msi installer that you downloaded from the website.)
- Follow the prompts in the installer (Accept the license agreement with default installation settings.
4. Restart your computer. You won’t be able to run Node.js® until you restart your computer.
To make sure that the NPM and Node have been installed successfully on your system you can check this just by typing commands in the command prompt.
- Test Node. To see if Node is installed, open Windows Command Prompt, Powershell, and type.
node -vThis should print the version number, something like
- Test NPM. And to test NPM just type in
npm -vthe Command Prompt or Powershell and it will show you something like this.
hello.jsand just add the code.
console.log('Everything Up and running');To run the code simply open your command line program, navigate to the folder where you save the file and type.
node hello.jsThis will start Node and run the code in the file
hello.js. You should see the output.
Everything Up and running
How to Update:-
Just got to the Node website and download the latest version and install it.
How to uninstall:-
Simply go to your control panel and uninstall the Node.js package.
Installation On Linux:-
In order to get it installed, we just need to use the
apt package manager on Debian Linux distros. First get updates form the servers and refresh local package index.
sudo apt-get update
sudo apt-get install nodejs
If the version of Nodejs in the repositories suits your needs, this is all that you need to do to get set up with Node.js. and in most cases you will also install
npm which is Node.js package manager typing:
sudo apt-get install npm
This will allow you to easily install modules and packages to use with Node.js.
Because of a conflict with another package, the executable from the Ubuntu repositories is called
nodejs instead of
node. Keep this in mind as you are running software.
Below, we’ll discuss some more flexible methods of installation.
Install Using PPA:-
An alternative way that you can you to install Node.js and you can get the more recent version of Node.js and its added in your PPA (Personal package archive).
First, you need to install the PPA in order to get access to its contents. This depends on the version you wish to install.
For the most recent LTS (8.x version) use:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
For the currently active version release (9.x version) use:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
After you have added this to your PPA you just need to run this command to install it.
sudo apt-get install nodejs
As this package
nodejs contains the
nodejs binary and
npm so we don’t have to install it separately. But in order to for
npm to work properly, we will have to install the required libraries on the system.
sudo apt-get install build-essential
How To Install Using NVM
An alternative to installing Node.js through
apt is to use a specially designed tool called
nvm, which stands for “Node.js version manager”.
Using nvm, you can install multiple, self-contained versions of Node.js which will allow you to control your environment easier.
First, Let’s install required packages.
sudo apt-get update sudo apt-get install build-essential libssl-dev
Now we want to run the
nvm installation file so we have to download it from GitHub:
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
This will download the script and run it. It will install the software into a subdirectory of your home directory at
~/.nvm. It will also add the necessary lines to your
~/.profile file to use the file.
To gain access to the nvm functionality, you’ll need to log out and log back in again, or you can source the
~/.profile file so that your current session knows about the changes:
Now that you have nvm installed, you can install isolated Node.js versions.
To find out the versions of Node.js that are available for installation, you can type:
. . . v0.11.6 v0.11.7 v0.11.8 v0.11.9 v0.11.10 v0.11.11 v0.11.12 v0.11.13
As you can see, the newest version at the time of this writing is v0.11.13. You can install that by typing:
nvm install 0.11.13
Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:
nvm use 0.11.13
When you install Node.js using nvm, the executable is called
node. The below command used to find exact node.js version.
below command used to find installed versions.
If you wish to default one of the versions, you can type:
nvm alias default 0.11.13
This will automitically select vesion. You can also reference it by the alias like this:
nvm use default