CLion 2017.3 Help

JavaScript

With CLion, you can develop modern web, mobile, and desktop applications with JavaScript and Node.js. CLion supports JavaScript and TypeScript programming languages, React and Angular frameworks and provides tight integration with various tools for web development.

On this page you will find a short Getting Started Guide that will walk you step by step from creating a web application to debugging and testing it.

Creating a new application

  1. Choose File | New | Project on the main menu or click Create New Project on the Welcome screen. The New Project Dialog opens.
  2. In the left-hand pane, choose Empty Project.
  3. In the right-hand pane, specify the path to the folder where the project-related files will be stored. Click Create.

Starting with an existing JavaScript application

If you are going to continue developing an existing JavaScript application, open it in CLion, choose the JavaScript version to use, and configure the libraries in it. Optionally download the required npm dependencies.

If the application sources are already on your machine
Click Open on the Welcome screen or choose File | Open on the main menu. In the dialog that opens, select the folder where your sources are stored.

If the application sources are under version control

  1. Click Check out from Version Control on the Welcome screen or choose VCS | Check out from Version Control on the main menu.
  2. Select your version control system from the list.
  3. In the VCS-specific dialog that opens, type your credentials and the repository to check out the application sources from.

Choosing the JavaScript language version

To get reliable and efficient coding assistance, you need to specify the language version that will be used in all JavaScript files of your application by default.

To choose the default JavaScript language version

  1. Open the JavaScript page: in the Settings/Preferences dialog (Ctrl+Alt+S), choose Languages and Frameworks | JavaScript .
  2. From the drop-down list, choose one of the supported JavaScript language versions:

Using multiple JavaScript versions

If you are working on an application that uses both ECMAScript 5.1 and a newer version of ECMAScript, or JSX, or Flow, the easiest way is to choose the highest language version for the whole project from the drop-down list on the JavaScript page. For example, if you use ES5.1 and JSX, enable JSX (since it is a superset of ES5.1 and ES6).

To configure different JavaScript language versions for different folders

  1. On the JavaScript page, click /help/img/idea/2017.3/browseButton.png next to the JavaScript language version drop-down list. The JavaScript Language Versions dialog opens.
  2. Click /help/img/idea/2017.3/add.png and in the dialog that opens select the folder where you need a custom language version. CLion brings you back to the JavaScript Language Versions dialog where the selected folder is shown in the Path field.
  3. From the Language drop-down list, choose the language version for the files in the selected folder. To all other JavaScript files in the project CLion will use the version chosen on the JavaScript page.

Downloading npm dependencies

If your application uses some tools, libraries, or frameworks, download the required packages.

  1. Download, install, and configure Node.js as described in Configuring Node.js Interpreters.
  2. Install and enable the NodeJS plugin on the Plugins page as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.

To install a package in an empty project
Open the embedded Terminal (View | Tool Windows | Terminal) and type npm install <package name> at the command prompt.

If you already have a package.json file in your project
Right-click the package.json file in the editor or in the Project tool window and choose Run 'npm install' on the context menu.

Running JavaScript in browser

  1. In the editor, open the HTML file with the JavaScript reference. This HTML file does not necessarily have to be the one that implements the starting page of the application.
  2. Do one of the following:
    • Choose View | Open in Browser on the main menu or press Alt+F2. Then select the desired browser from the pop-up menu.
    • Hover your mouse pointer over the code to show the browser icons bar: /help/img/idea/2017.3/browserIcons.png Click the icon that indicates the desired browser.

Debugging JavaScript

CLion provides a built-in debugger for your client-side JavaScript code that works with Chrome.

You can also debug your client-side JavaScript in Firefox, version 36 and higher. However it is strongly recommended that you use Chrome or any other browser of the Chrome family. With CLion, you can debug JavaScript applications running on the built-in server, on an external server, or on a remote server. For details, see Debugging JavaScript in Chrome and Debugging JavaScript in Firefox.

Last modified: 24 October 2017

See Also