0

How do I run JavaScript code in Visual Studio Code? I want to run console.log('Hello, World!);, but I don't know how. Do I need to install an extension?

2
  • 2
    What kind of environment are you trying to run it in? Is it browser-based or node? Commented Mar 3, 2021 at 6:45
  • Maybe Node, I'm not using a browser. Commented Mar 3, 2021 at 6:48

4 Answers 4

3

You can install node.js first. Then run the terminal in vscode with the command: node namefile

Sign up to request clarification or add additional context in comments.

Comments

0

You can see the log in the browser just press F12 in the browser and select console you will be able the see log details there.

Comments

0

You can use vscode extension Code Runner https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

enter image description here

Comments

0
  1. you need to install NodeJS. You can install it from here: https://nodejs.org/en/

  2. Create a new folder and open it in VS Code. then write the javascript code and name it with extension .js After completing the code save the changes that you made

  3. Open the terminal in VS Code. and make sure you are in your project folder (cd yourproject)

  4. finally run this command: node yourjsfilename

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.