In this section:
PhpStorm supports integration with the Node.js runtime environment thus enabling running, debugging, and unit testing of Node.js applications.
PhpStorm recognizes Node.js code and provides basic coding assistance and highlighting for it. To get guidance in Node development, see HowToNode.org.
Before you start
- Download and install the Node.js runtime environment.
- Install and enable the NodeJS plugin. The NodeJS plugin is not bundled with PhpStorm, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
- Node.js page is added to the Settings dialog box.
- Run/debug configurations are added.
Configuring Node.js in PhpStorm
- Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or for OS X, and click Node.js and NPM under Languages & Frameworks. The Node.js and NPM page opens.
- In the Node Interpreter field,
specify the local Node.js interpreter to use.
Choose the interpreter from the drop-down list or click and choose the interpreter in the dialog box that opens.
The term local Node.js interpreter denotes a Node.js installation on your computer. The term remote Node.js interpreter denotes a Node.js installation on a remote host or in a virtual environment set up in a Vagrant instance. On the Node.js and NPM page, you can specify only local interpreters. Remote interpreters are configured in the Configure Node.js Remote Interpreter Dialog dialog which can be accessed only from the Run/Debug Configuration: Node JS dialog. See Configuring Node.js Interpreters for details.
In the Code Assistance area, configure the Node.js core module sources if they are not configured yet.
When developing a Node.js application it can be convenient to have code completion, reference resolution, validation, and debugging capabilities for Node core modules (
If the Node.js core module sources are not set up, PhpStorm displays a notification
Node.js Core Library is not enabled
with an Enable button.
Click this button to have PhpStorm configure Node.js Core sources
When the configuration is completed, PhpStorm displays information about the currently configured version, the notification Node.js Core Library is enabled, and adds two buttons: the Disable button and the Usage scope button.
- If the library is set up, PhpStorm displays information about the currently configured version, the notification Node.js Core Library is enabled, and adds two buttons: the Disable button and the Usage scope button.
- If the Node.js core module sources are not set up, PhpStorm displays a notification Node.js Core Library is not enabled with an Enable button. Click this button to have PhpStorm configure Node.js Core sources automatically.
If necessary, configure the scope in which the Node.js Core sources are treated as libraries.
Click the Usage scope button, and in the Usage Scope dialog box that opens,
click the desired directories, and from the drop-down list select the newly configured Node.js core module sources library.
The use of a library is enabled recursively, that is, if a library is associated with a folder it is automatically enabled in all the nested directories and files.