sudo npm install nodejs
If you already installed then the the following things will be shown in the screenshot below.
Then check the npm and node version by typing the following commands
The above result will be shown when you type those two commands to check the node and npm version.
Now you need to install the Visual Studio Code into your computer. There are also very simple steps to installing the Visual Studio code into your machine.
Simply type the following command to install the Visual Studio code to your machine.
sudo snap install code –classic
Open Visual Studio code program
When you install it for the first time in your computer the above display will be of Visual Studio Code.
Now Create a folder on the desktop which is named “js-program”. Go to File -> Open Folder And select the folder which you created from desktop by using the browser window. And click ok.
Now that folder will be opened to your Visual Studio Code Like below screenshot.
Now right click on below of your folder name and click on “new file” option. And name that file as “index.js”. And hit Enter key a new file will be opened to your web browser like the below screenshot.
Now write the code like below screenshot in that “index.js” file.
Press “CTRL+S” Key to save the file.
Now go to terminal -> new terminal to open and create a new terminal window. On the bottom side of your Visual Studio Code a tab will be shown like the screenshot below.
In terminal type the following commands to run your index.js file.