In this blog post, I will show you how to run JavaScript program in Visual Studio code using a code runner VS CODE extension. You will learn how to use the VS Code terminal to run JavaScript code. To see the output of the javascript program, you need to install the node js file into your computer.
How to Run JavaScript Program in Visual Studio Code?
This article will also show you how to fix the “Node is not recognized as an internal or external command” error in Visual Studio code. Also, the node is not recognized as an internal or external command in the Visual Studio code terminal. And, the node is not recognized as an internal or external command in visual studio code.
How to see the JavaScript output in the browser?
If you are a beginner developer you can also display the output of JavaScript code in a web browser. To see the output, the console.log(); statement prints anything in the browser console.
Look for the Developer Tools or Simply Tools menu in all major browsers you are using. If you are using Google Chrome press Cntrl+shift+j to see the console section.
How to see the JavaScript output in the vs code?
Now in this post, you will learn How To Run JavaScript Program in Visual Studio Code Terminal. To see the output in VS Code you need to install an extension named, Code Runner for the Visual Studio code marketplace. Go through the following steps to Run JavaScript Program in Visual Studio Code.
- Open your Visual Studio code editor
- Write any JavaScript code to see the output
- including the console.log(); statement with the output variable inside the parentheses.
- Install the JavaScript Code Runner extension in your VS Code
- Download and Installing node js files in your computer
- Right-click and choose the Run Code option to see the output in vs code terminal
Video Tutorial:
You can watch the complete video tutorial on how to Run JavaScript Program in Visual Studio Code below. In this video tutorial, I have included a step-by-step process with all the practical steps to see the output in VS Code editor.
Now, I will explain the process in steps. Just these steps and run any code in your Visual Studio code editor.
1) Writing JavaScript code in Visual Studio Code
First of all, open your VS CODE editor window and create a javascript file i.e. anyname.js. Then Write any JavaScript code to see the output. In this post, I am going to write a simple JavaScript code for the sum of two numbers. Just to show you how can you see your code output in the Visual Studio Code terminal panel. The code is given below.
function sum(x, y){
// add two numbers and return result
return x + y;
}
// call function
let n = sum(10, 18);
// display the output
console.log(n);
//end of program
To display the output of JavaScript code console.log(n); the command is used in the program.
2) Install Code Runner extension in VS Code
After that install the Code Runner extension in your Visual Studio Code. By using this extension you can run any code and see the output in the terminal of visual studio code. To install this extension go to the extension icon in your VS Code and search the Code Runner as shown in the image below.

3) Run JavaScript Code in VSCODE
After installing the Code Runner extension, run the code. To see output just right-click on the editor window and choose the first option, Run Code from the popup window as shown in the image below.

Now after running the code, some developers will face the following terminal error in Visual Studio Code:
'node' is not recognized as an internal or an external command, operable program or batch file.

4) How to Fix ‘node’ is not recognized error VSCODE
Now we are going to fix this error. To fix this error you need to download and install the Node js files in your Windows and include the file path in the Environment Variables in the advanced system settings on your computer.
To download the Node js files go to This Link and install the installer setup on your computer as shown in the image below.

5) How to include the path in the environment variable?
To add a file path to the PATH environment variable on your computer in the System dialog box:
- Go to Advanced system settings.
- On the Advanced tab of the System Properties dialog box, click Environment Variables.
- In the System Variables box of the Environment Variables dialog box, scroll to Path and select it

I have also explained the process in the steps in the above video tutorial. You can watch the video for a complete understanding.
6) How to see the output in VS Code
Finally, After setting up the file path again right-click on the code editor and select the run code option to see the output in the VS Code terminal.
