Hello Readers, Welcome to Node js Installation blog, we will learn Node js installation. It helps beginners to install node js QUICK.
Table of Contents
Node JS Installation
Node js Installation is the most important and required step for any javascript based frontend development(Angular, React, VueJs) or backend development (NodeJs, Express and many more).
Let’s learn to Install Node very easy and fast way
Node Js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser.
Pre-requisites:
This guide assumes that you are using Ubuntu 16.04. Before you begin, you should have a non-root user account with sudo privileges set up on your system.
Keep in Mind Points:
[1] Always prefer to install and use the LTS(Long Term Support) version of nodejs
[2] Make sure you have Root access. Use sudo for commands in blog
[3] Check and Verify all the file permission[sudo chmod R -755 file-name]
Node Js Installation
Installing Node.js through apt
Node.js installation through apt is to use a specially designed tool called nvm, which stands for “Node.js version manager”. It is fast, easy, and better technique for node js installation in ubuntu.
nvm works at the level of an independent directory within your home directory. This means that you can install multiple, self-contained versions of Node.js without affecting the entire system.
Controlling your environment with nvm allows you to access the newest versions of Node.js and retain and manage previous releases. It is a different utility from apt-get, however, and the versions of Node.js that you manage through it are distinct from the distro-stable version of Node.js available from the Ubuntu repositories.
To start off, we’ll need to get the software packages from our Ubuntu repositories that will allow us to build source packages. The nvm script will leverage these tools to build the necessary components:
Step:1 Update software packages from ubuntu and build the components
Type the Following two commands one by one:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
Step:2 Install curl OR wget
Once the prerequisite packages are installed, you can pull down the nvm installation script from the project’s GitHub page. The version number may be different, but in general, you can download it with curl or wget:
Download wget/curl if not available:
sudo apt install curl
or
sudo apt install wget
Go to this below and save this file as “install_nvm.sh” name in the /home directory. https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh
sudo curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh
sudo wget -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh
Step:3 Give Permission and Run the script via bash
Go to the directory where you have downloaded the above sh file “install.sh”. This bash file will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary configuration lines to your ~/.profile file to use the file.
Must Note: Give all the permission “install_nvm.sh”.
sudo chmod 777 -R {path of install_nvm.sh}
Then Fire below Command:
bash install_nvm.sh
Step:4 Reload the Profile:
It is recommended to reload the profile again to see reflected new configuration changes. To access the nvm functionality, you’ll need to close the file and re-run the command ‘source the ~/.profile’ again in the terminal screen.
source ~/.profile
Step:5 Check All Available Remote Node Versions
Wow, you have installed nvm. Now, you can install isolated Node.js versions. To find out the versions of Node.js that are available for installation, you can type:
nvm ls-remote
Output
Step:6 Install Node LTS Version via NVM
As you can see, the newest LTS version at the time of this writing is v8.9.4. You can install that by typing:
nvm install 10.15.0
Step:7 Use the Specific Node Version
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 10.15.0
Step:8 Set Default Node Version / Set Alias Default
It is recommended to set the default alias or default node version through the ‘nvm alias default’ command.
Sometimes we face the issue of ‘Node is not installed’ error when changing a new terminal or after restart the system. If you wish to default one of the versions, you can type:
nvm alias default 10.15.0
You can learn more about the options available to you with nvm by typing:
nvm help
Step:9 Check and Verify Node Version
When you install Node.js using nvm, the executable is called a node. You can see the version currently being used by the shell by typing:
node -v
Output
Step:10 Check and Verify NPM Version
npm -v
Explore More NVM Commands:
Display All Multiple Installed Node Version
If you have multiple Node.js versions, you can see what is installed by typing:
nvm ls
Remove Node version:
To uninstall a version of Node.js that you have enabled using nvm, first determine whether or not the version you would like to remove is the currently active version:
nvm current
If the version you are targeting is not the current active version, you can run:
nvm uninstall node_version
If the version you would like to remove is the current active version, you must first deactivate nvm to enable your changes:
nvm deactivate
What’s NEXT?
YOU ARE the Warrior, Yes Right, You have achieved the first hardest MILESTONE ‘Node js installation’ for any javascript-based frontend or backend development
Now You can quick start with 5 minutes to create react app
Conclusion
I hope Node Installation was smooth. We have covered everything for node installation. Anyhow, if you encounter any issues while installing, follow Node's documentation or ensure you have root access (Use sudo for mentioned commands). If you still face challenges, you can contact us. We are ready to help you.
After Node JS Installation, you have the superpower to choose and start front-end development using the most popular frameworks.
For Backend development technologies, you can explore articles on Aspire Softserv mobile development.
Last but not least, feedback is good practice if you have read an article. Please comment and share your thoughts; we'd love to hear. Connect with us to explore the possibilities!