Configuring Node.js Interpreters
On this page:
- Introduction
- Configuring a local Node.js interpreter
- Configuring a remote Node.js interpreter on a host accessible through SSH connection
- Configuring a remote Node.js interpreter in a Vagrant environment instance
- Configuring a remote Node.js interpreter on a remote host accessible through SFTP
- Configuring mappings
Introduction
With WebStorm, you can use local and remote Node.js interpreters.
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.
You can access a remote interpreter in three ways:
- Using SSH credentials to access the host where the Node.js interpreter is installed.
- Through access to the corresponding Vagrant instance.
- According to a Server Access Configuration. This approach is also helpful if you are going to synchronize your project sources with the Web server on the target remote host.
Configuring a local Node.js interpreter
- 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.
-
On the Node.js and NPM page that opens, click the
button next to the Node Interpreter drop-down list.
-
In the Node.js Interpreters Dialog that opens with a list of all the currently configured interpreters,
click
in the toolbar. In the dialog box that opens, choose Add Local on the context menu , then choose the local installation of Node.js.
The path to the chosen interpreter is shown in Node.js Interpreters Dialog.
Configuring a remote Node.js interpreter on a host accessible through SSH connection
Before you start:
-
Configure access to an
ssh
server on the target remote host and make sure this server is running. - Make sure the Node.js Remote Interpreter plugin is enabled. The plugin is bundled with WebStorm and activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
To configure a Node.js interpreter using SSH credentials:
-
On the main menu, choose .
In the Edit Configuration dialog box, that opens, click the Add New Configuration toolbar button
, and choose Node.js on the context menu. In the Run/Debug Configuration: Node JS dialog that opens, click
next to the Node interpreter field.
-
In the Node.js Interpreters Dialog that opens with a list of all the currently configured interpreters,
click
in the toolbar. In the dialog box that opens, choose Add Remote on the context menu .
- In the Configure Node.js Remote Interpreter Dialog that opens, choose the SSH Credentials method.
- Specify the name of the remote host and the port which the SSH server listens to. The default port number is 22.
-
Specify your credentials to access the remote host in accordance with the credentials received during the registration on the server.
Type your user name and choose the authentication method:
- To access the host through a password, choose Password from the Auth type drop-down list and type the password.
- To access the host through a pair of SSH keys, choose Key pair, then specify the path to the file where your private key is stored or the passphrase if you have configured it during the generation of the key pair.
-
Specify the location of the Node.js executable file in accordance with the development environment
configured on the selected remote host.
By default WebStorm suggests the
/usr/bin/node
folder. To specify another folder, click the Browse buttonand choose the relevant folder in the dialog box that opens. Note that the Node.js home directory must be open for edit.
-
When you click OK, WebStorm checks whether the Node.js executable is actually stored in the specified folder.
- If no Node.js executable is found, WebStorm displays an error message asking you whether to continue searching or save the interpreter configuration anyway.
- If the Node.js executable is found, you return to the Node.js Interpreters where the installation folder and the detected version of the Node.js interpreter are displayed.
Configuring a remote Node.js interpreter in a Vagrant environment instance
Before you start:
- Make sure that Vagrant and Oracle's VirtualBox are downloaded, installed, and configured on your computer as described in Vagrant: Working with Reproducible Development Environments.
- Make sure the Vagrant plugin is enabled. The plugin is bundled with WebStorm and activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
- Make sure the Node.js Remote Interpreter plugin is enabled. The plugin is bundled with WebStorm and activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
- Make sure that the parent folders of the following executable files are added to the system PATH variable:
- Configure the Node.js development environment in the Vagrant instance to be used. Learn more about using Vagrant with WebStorm in Vagrant: Working with Reproducible Development Environments.
To configure a Node.js Interpreter in a Vagrant instance
-
On the main menu, choose .
In the Edit Configuration dialog box, that opens, click the Add New Configuration toolbar button
, and choose Node.js on the context menu. In the Run/Debug Configuration: Node JS dialog that opens, click
next to the Node interpreter field.
-
In the Node.js Interpreters Dialog that opens with a list of all the currently configured interpreters,
click
in the toolbar. In the dialog box that opens, choose Add Remote on the context menu .
- In the Configure Node.js Remote Interpreter Dialog that opens, choose the Vagrant method.
- Specify the Vagrant instance folder which points at the environment you are going to use. Technically, it is the folder where the VagrantFile configuration file for the desired environment is located. Based on this setting, WebStorm detects the Vagrant host and shows it as a link in the Vagrant Host URL read-only field.
-
Specify the location of the Node.js executable file in accordance with the development environment
configured in the selected Vagrant instance.
By default WebStorm suggests the
/usr/bin/node
folder. To specify another folder, click the Browse buttonand choose the relevant folder in the dialog box that opens. Note that the Node.js home directory must be open for edit.
-
When you click OK, WebStorm checks whether the Node.js executable is actually stored in the specified folder.
- If no Node.js executable is found, WebStorm displays an error message asking you whether to continue searching or save the interpreter configuration anyway.
- If the Node.js executable is found, you return to the Node.js Interpreters where the installation folder and the detected version of the Node.js interpreter are displayed.
Configuring a remote Node.js interpreter on a remote host accessible through SFTP
Before you start:
-
Make sure a
ssh
server is running on the target remote host and you have configured access to it. - Make sure the Node.js Remote Interpreter and Remote Hosts Access plugins are enabled. The plugins are bundled with WebStorm and activated by default. If the plugins are not activated, enable them on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
- Make sure you have at least one WebStorm-wide server access configuration of the type SFTP to establish access to the target host. To make a configuration available in all WebStorm projects, clear the Visible only for this project check box in the Deployment: Connection Tab. See Creating a Remote Server Configuration for details.
To configure a remote Node.js interpreter based on an SFTP server access configuration
-
On the main menu, choose .
In the Edit Configuration dialog box, that opens, click the Add New Configuration toolbar button
, and choose Node.js on the context menu. In the Run/Debug Configuration: Node JS dialog that opens, click
next to the Node interpreter field.
-
In the Node.js Interpreters Dialog that opens with a list of all the currently configured interpreters,
click
in the toolbar. In the dialog box that opens, choose Add Remote on the context menu .
- In the Configure Node.js Remote Interpreter Dialog that opens, choose the Deployment Configuration method.
-
From the Deployment Configuration drop-down list,
choose the server access configuration of the type SFTP
according to which you want WebStorm to connect to the target host. If the settings specified in the chosen configuration ensure successful connection,
WebStorm displays the URL address of the target host as a link in the Deployment Host URL field.
To use an interpreter configuration, you need path mappings that set correspondence between the project folders, the folders on the server to copy project files to, and the URL addresses to access the copied data on the server . By default, WebStorm retrieves path mappings from the chosen server access (deployment) configuration. If the configuration does not contain path mappings, WebStorm displays the corresponding error message.
To fix the problem, open the Deployment page under the Build, Execution, Deployment node, select the relevant server access configuration, switch to the Mappings tab, and map the local folders to the folders on the server as described in Creating a Remote Server Configuration, section Mapping Local Folders to Folders on the Server and the URL Addresses to Access Them.
-
Specify the location of the Node.js executable file in accordance with the development environment
configured on the selected remote host.
By default WebStorm suggests the
/usr/bin/node
folder. To specify another folder, click the Browse buttonand choose the relevant folder in the dialog box that opens. Note that the Node.js home directory must be open for edit.
-
When you click OK, WebStorm checks whether the Node.js executable is actually stored in the specified folder.
- If no Node.js executable is found, WebStorm displays an error message asking you whether to continue searching or save the interpreter configuration anyway.
- If the Node.js executable is found, you return to the Node.js Interpreters where the installation folder and the detected version of the Node.js interpreter are displayed.
Configuring mappings
When you debug an application with a remote Node.js interpreter, the debugger tells WebStorm the name of the currently processed file and the number of the line to be processed. WebStorm opens the local copy of this file and indicates the line with the provided number. This behaviour is enabled by specifying correspondence between files and folders on the server and their local copies. This correspondence is called mapping, it is set in the debug configuration.
If you use an interpreter accessible through SFTP connection or located on a Vagrant instance,
the mappings are automatically retrieved from the corresponding deployment configuration or Vagrantfile
.
To specify additional mappings:
-
On the main menu, choose .
In the Edit Configuration dialog box, that opens, click the Add New Configuration toolbar button
, and choose Node.js on the context menu.
- In the Run/Debug Configuration: Node JS dialog that opens, choose the required remote interpreter from the Node interpreter drop-down list.
-
Click
next to the Path Mappings field.
-
The Edit Project Path Mappings Dialog that opens, shows the path mappings retrieved from the
deployment configuration or
Vagrantfile
. These mappings are read-only.-
To add a custom mapping, click
and specify the path in the project and the corresponding path on the remote runtime environment in the Local Path and Remote Path fields respectively. Type the paths manually or click
and select the relevant files or folders in the dialog box that opens.
-
To remove a custom mapping, select it in the list and click
.
-
To add a custom mapping, click