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?
-
2What kind of environment are you trying to run it in? Is it browser-based or node?Liftoff– Liftoff2021-03-03 06:45:51 +00:00Commented Mar 3, 2021 at 6:45
-
Maybe Node, I'm not using a browser.galdeeb-dev– galdeeb-dev2021-03-03 06:48:40 +00:00Commented Mar 3, 2021 at 6:48
Add a comment
|
4 Answers
You can use vscode extension Code Runner https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
Comments
you need to install NodeJS. You can install it from here: https://nodejs.org/en/
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
Open the terminal in VS Code. and make sure you are in your project folder (cd yourproject)
finally run this command: node yourjsfilename
