How To Run JavaScript Program in Visual Studio Code Terminal

How to run Javascript program visual studio code
How to run Javascript program visual studio code
Spread the love, Share this Article!

Subscribe to Our YouTube Channel!

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 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 execute a javascript program in VS 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 JavaScript output in 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 the press Cntrl+shift+j to see the console section.

How to see the JavaScript output in the VSCODE?

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. And go through the following steps to Run JavaScript Program in Visual Studio Code.

  1. Open your visual studio code editor
  2. Write any JavaScript code to see the output
  3. include the console.log(); statement with output variable insite the parentheses.
  4. Install JavaScript Code Runner extension in your VS Code
  5. Download and Installing node js files in you computer
  6. Right click and choose Run Code option to see output in vscode terminal

Video Tutorial:

You can watch the complete video tutorial on how to run JavaScript code in visual studio code below. In this video tutorial, I have included a step by step process with all practical steps to see output in VS Code editor.

How To Run JavaScript Program in Visual Studio Code

Now, I will explain the process in steps. Just 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 VSCODE editor window and create a javascript file i.e. anyname.js. Then Write any JavaScript code to see 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 Visual Studio Code terminal pannel. 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); command is used in the program.

2) Install Code Runner extension in VS Code

After that install the Code runnr extension in your Visual Studio Code. By using this extension you can run any code and see 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.

Code runner extension visual studio code
Code runner extension visual studio code

3) Run JavaScript Code in VSCODE

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

Run javascript code in VS Code
Run javaScript code in VS Code

Now after running the code some developer 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.
Fix node is not recognized error in visual studio code
Fix node is not recognized error in visual studio code

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 in your computer.

To download the Node js files got to This Link and install the installer setup on your computer as shown in the image below.

How to install node js on your computer
How to install node js on your computer

5) How to include path in 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 explained the process in the steps in the above video tutorial. You can watch the video for complete understanding.

Edit Environment variable on your computer
Edit Environment variable on your computer

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 VS Code terminal.

See JavaScript Output in VSCODE
See JavaScript Output in VSCODE

Hit The Subscribe Button to Get Daily New video!

Spread the love, Share this Article!

Important Tags:

7 Responses

  1. I’ve been absent for some time, but now I remember why I used to love this site. Thank you, I will try and check back more often. How frequently you update your web site?

  2. I must thank you for the efforts youve put in penning this site. I am hoping to check out the same high-grade blog posts by you in the future as well. In fact, your creative writing abilities has motivated me to get my very own blog now 😉

  3. Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but instead of that, this is great blog. A fantastic read. I’ll definitely be back.|

Leave a Reply

Your email address will not be published.