In this tutorial, I will cover How to Install Node ?
Welcome to Mrvirk.com, I am your host Navjot Singh and I will be responsible for guiding you in this tutorial.
1- To install node, visit nodejs.org and go to the downloads page – https://nodejs.org/en/download/
2- Download Node based on your operating system – Mac, Windows PC, Linux or others.
In this tutorial, I will be installing node on a Macbook Pro. The steps for other platforms may differ slightly based on the platform.
3- Install Node using the pre-built installer
Check if I have Node Installed
To check if you have, Node installed on your machine –
Open Terminal (Mac) or Command Line (Windows PC) and run the command below –
If the command runs successfully, it means Node is installed and it will also return the version of Node installed on your machine, and if it fails it means Node is not installed.
Check the version of npm
To check the version of npm installed on your machine, simply run the command below –
Running a JS file using Node
Use the keyword “node” and the file name as seen in example below (and dont forget to change directory to where your JS file is located)
Below is the code file covered in the video tutorial for quick reference.
console.log("Congratulation! Node is currently installed in your computer"); console.log("Yeah I did it"); /* 1- How to install node 2- Checking the if node is installed and its version node -v 3- Checking the version of npm npm -v 4- Running a JS file using Node node name_of_your_file.js 5- Upating Node sudo npm cache clean -f sudo npm install -g n sudo n stable 6- Installing a package using npm 7- Installing a package using bower */
To update node on your machine, run the commands below –
sudo npm cache clean -f sudo npm install -g n sudo n stable