IntelliJ IDEA 2018.1 Help

Node.js

Node.js is a lightweight runtime environment for executing JavaScript on the server side. IntelliJ IDEA integrates with Node.js providing assistance in configuring, editing, running, debugging, testing, profiling, and maintaining your applications.

Before you start

  1. Download and install the Node.js runtime environment.
  2. Install and enable the NodeJS plugin. The NodeJS plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.

Quick start with a Node.js application

Here we will use a simple Express application as an example.

To create an application

  1. Choose File | New | Project on the main menu or click the New Project button on the Welcome screen.
  2. In the Project Category and Options dialog, which is the first page of the New Project wizard, choose Node.js and NPM in the left-hand pane.
  3. In the right-hand pane, choose Node.js Express App and click Next.
  4. On the second page of the wizard, specify the project folder, the Node.js interpreter, and the version of express-generator to use. In the Options area, choose the template language and the Style Sheet language to use.
  5. When you click Finish, IntelliJ IDEA generates a Node.js Express-specific project with all the required configuration files.

To download the project dependencies, do one of the following:

  • Open the embedded Terminal (View | Tool Windows | Terminal) and type npm install at the command prompt.
  • Choose Run 'npm install' on the context menu of the package.json file in your project root.

To configure Node.js in a project

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), click Node.js and NPM under Languages and Frameworks. The Node.js and NPM page opens.
  2. In the Node Interpreter field, specify the default Node.js interpreter for the current project. IntelliJ IDEA will automatically use it every time you select the Project alias from Node Interpreter lists when creating run/debug configurations or configuring Node.js-dependent tools, for example, Prettier or Yeoman.

    Choose the interpreter from the drop-down list or from the dialog that opens when you click browseButton. If you choose node, the system Node.js version is used.

  3. Select the Coding assistance for Node.js checkbox to configure the Node.js Core module sources as a JavaScript library and associate it with your project. As a result, IntelliJ IDEA provides code completion, reference resolution, validation, and debugging capabilities for fs, path, http, and other core modules that are compiled into the Node.js binary.

    When the configuration is completed, IntelliJ IDEA displays information about the currently configured version.

  4. Optionally, configure the scope in which the Node.js Core sources are treated as libraries:
    1. Click Manage scopes. The Usage Scope dialog opens.
    2. Click the relevant directories, and for each of them select the newly configured Node.js Core library from the list.
Last modified: 4 April 2018

See Also