- Create a Node.js run configuration.
-
To launch the application, select the run configuration from the list on the main tool bar
and then choose on the main menu or click the Run toolbar button
.
-
In the Run tool window, that opens, copy the URL address at which the application is running. The URL address is specified in the following information message:
Server running at http://<host>:<port>/ - Open the browser of your choice and open the page with the copied URL address. The page shows the result of executing your Node.js application.
- Set the breakpoints in the Node.js code, where necessary.
- Create a Node.js run/debug configuration.
-
To start a debugging session, select the debug configuration from the list on the main tool bar
and then choose on the main menu or click the Debug toolbar button
.
-
In the Console tab of the Debug tool window, that opens, copy the URL address at which the application is running.
The URL address is specified in the following information message:
Server running at http://<host>:<port>/ - Open the browser of your choice and open the page with the copied URL address. Control over the debugging session returns to PhpStorm.
- Switch to PhpStorm, where the controls of the Debug tool window are now enabled. Proceed with the debugging session step through the breakpoints, switch between frames, change values on-the-fly, examine a suspended program, evaluate expressions, and set watches. :
The procedure falls into two parts: first we start an application as usual and then connect to it with the debugger.
- Set the breakpoints in the Node.js code, where necessary.
- Create a Node.js run configuration with the following option in the Node parameters text box: --debug==<port for connect to debugger remotely>
- Run the application with the created configuration.
- Create a Node.js Remote Debug configuration: in the Debug port text box, type the port number specified in the currently running Node.js configuration.
-
With the application still running, launch the Node.js Remote Debug configuration (select the configuration in the list
and click the Debug toolbar button
).
- In the Run tool window, copy the URL address of the server and open the corresponding page in the browser. Control over the debugging session returns to PhpStorm.
- Switch to PhpStorm. In the Debug tool window, step through the breakpoints, switch between frames, change values on-the-fly, examine a suspended program, evaluate expressions, and set watches.
- 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 box, that opens, specify the following:
- The name of the configuration.
-
The path to the Node.js executable file.
Note
This field is already filled in if you have appointed a default installation.
- To enable remote debugging of the application, specify the following option in the Node parameters text box: --debug==<port for connect to debugger remotely>
- The location of the file to start running the Node.js application.
- If the file to run references any other files, specify their location in the Working directory field.
-
If applicable, in the Application parameters text box, specify the arguments to be passed to the application on start
through the process.argv
array.
- Click OK, when ready.
- On the main menu, choose .
-
In the Edit Configuration dialog box, that opens, click the Add New Configuration toolbar button
,
and choose Node.js Remote Debug on the context menu.
-
In the Run/Debug Configuration: Node.js Remote Debug dialog box, that opens, specify the following:
- The name of the configuration.
- The host where the target application is running.
- The port to connect to. Copy the port number from the information message in the Run tool window that controls the running application.
- Click OK, when ready.
