Run Javascript In Visual Studio Code



Visual Studio Code supports many features for JavaScript and Node.js development. The features that ship with the downloaded product are the core features: debugging, IntelliSense, code navigation, etc.

  1. Run Js Visual Studio Code
  2. Typescript Vscode

Visual Studio Code supports many features for JavaScript and Node.js development. The features that ship with the downloaded product are the core features: debugging, IntelliSense, code navigation, etc. In addition, to these core features, you can install a large number of quality extensions to add features to VS Code for JavaScript development. To define our code as a JavaScript project, create jsconfig.json at the root of your JavaScript code as shown below. A JavaScript project is the source files of the project and should not include the derived or packaged files (such as a dist directory). In more complex projects, you may have more than one jsconfig.json file defined inside a workspace. You will want to do this so that the source code in one.

In addition, to these core features, you can install a large number of quality extensions to add features to VS Code for JavaScript development.

Tip: To see how to install and manage your extensions, please refer to the extension documentation.

Visual

Finding extensions

You can find JavaScript extensions by typing JavaScript in the Extension view search bar. Alternatively, you can find JavaScript extensions using tags: 'tag:javascript'. Search for more extensions in VS Code or in the Marketplace.

In addition you can search for Node.js extensions.

Tip: The extensions shown above are dynamically queried. Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.

Recommended extensions

If you are just getting started, here are the extensions we recommend trying out.

ESLint

Marketplace - ESLint

Publisher - Dirk Baeumer

Easily integrate ESLint into your project. If ESLint isn't your favorite linter, choose among a variety of other linter extensions, including JSHint, JSCS, and JS Standard.

Read more about setting up JavaScript linters in the VS Code documentation.

JavaScript (ES6) code snippets

Marketplace - JavaScript (ES6) code snippets

Publisher - charalampos karypidis

VS Code comes with many built-in code snippets. The JavaScript (ES6) code snippets extension adds snippets for ES6 (ECMAScript 6) syntax. Here is a small sampling of the snippets provided by this extension. See the extension's README to see the dozens of snippets this pack gives you.

You can read more about JavaScript snippets in the VS Code documentation. For additional snippet packs, including Angular 1, Angular 2, Bootstrap 3, ReactJs, and jQuery, check out the Marketplace's Snippets category.

npm IntelliSense

Marketplace - npm IntelliSense

Publisher - Christian Kohler

This extension provides IntelliSense for npm modules when using require or import.

Debugger for Chrome

Marketplace - Debugger for Chrome

Publisher - Microsoft

When you develop for the front end, you might not see the value of an integrated debugger in your editor. You use the browser's debugger right? This is where the Debugger for Chrome extension comes in. This extension lets you debug your JavaScript code in the Google Chrome browser, or any other targets that support the Chrome Debugging Protocol while staying in VS Code. No more context switching to debug!

Prefer to debug using a different browser? You can find extensions for Edge and Firefox as well.

In this article, we show how to run a node.js Script with Visual Studio Code software.

Javascript

Visual Studio Code is a very popular and used software to run node.js scripts.

In this article, we will create a very basic node.js script.

What we want to do is just go through the process of how to run a Script successfully.

So what you need to do is open up the Visual Studio Basic Software

You then want to create a Open up the Tab, New File.

You can call this file any name you want but the file needs to have .js file extension.

Run javascript in visual studio code terminal

Remember that node.js scripts are Javascript files. node.js are Javascript files run on the server side; however, just like plain Javascript, which is run on the front end, node.js scripts are Javascript files. Therefore, they must end with the extension .js.

So, you can save this file as firstprogram.js

Next, in this file, place in the following code.

So this is a simple script that will output the string when it runs in the terminal successfully.

So the first thing you put do is click on the Terminal tab at the bottom of the software. If you can't find this, go to the top panel and click on the Terminal tab and Select New Terminal.

When the Terminal is open, it should look like the following shown below.

Next make sure that the file that you want to run is within the directory that you're in on the terminal.

You can see in the terminal above, the current working directory is the notes directory. This is the directory which contains the file that we want to run. Therefore, the path is correct. If it wasn't, then you have to manually adjust it, such as by using the cd command.

After this, in the terminal, you specify the following.

So in order to run a script in node.js, you must specify the word, node, followed by the name of the file, including the file extension, which will be .js with node.js.

This will execute the node.js script.

Once you do so, you should see the output, 'Congratulation! You got node.js to run'

This is shown in the terminal below.

And this is it. You have officially run a node.js script in Visual Studio Code.

Remember that in order to run a node.js script in Visual Studio Code, you do so through the terminal near the bottom of the software.

You make sure that you are in the correct directory and then you use the word, node, followed by the filename you want to run.

This will run the node.js script.

Codecademy

And this is how to run a node.js script with Visual Studio Code software.

Related Resources

Run Js Visual Studio Code

How to Find the Version of node.js Installed on Your Computer

Typescript Vscode