Phpstorm Nodejs



Skip to end of metadataGo to start of metadata

This tutorial describes how to run and debug Node.js applications in WebStorm.
Go to this tutorial for getting started with Node.js in WebStorm.

  1. Now PhpStorm from what I know should have everything that WebStorm has plus the PHP support. I was trying to get PhpStorm setup to run testacular test wuthin the application and I saw a few video on how to do this with WebStorm however it show you need to create a NodeJS run configuration however there is no NodeJS configuration option.
  2. Node.js Program in PhpStorm configure Node.js Program in PhpStorm.

Webstorm Node.js debugging with Nodemon. I recently switched to the Webstorm IDE, and found that I couldn’t run the debugger when using nodemon to run my project. For those of you who haven’t tried nodemon, it’s a small package that automatically restarts your node project when it detects a file change; allowing for quick debugging. Install and integrate Node.js into PhpStorm. In case you have not already done so, download and install Node.js with the package manager npm and integrate both into PhpStorm. See my post on Use JSDoc 3 and PhpStorm to generate JavaScript documentation for more detail. Install the command line interface for CSSO. Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.Node.js lets developers use JavaScript to write command line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.

Running Node.js app locally

To run your Node.js application locally on your machine, you need to create a new Node.js Run/Debug configuration.

Click Edit configurations in the top right-hand corner of the IDE window or in the main menu Run.

Сlick + to add a new configuration and seleсt Node.js type.

Specify the path to the JavaScript file that needs to be executed. You can also add any parameters you need to pass to the node (Node parameters input) or to your application (Application parameters input) on the start.

Phpstorm

Phpstorm Node

Select this new configuration from the drop-down list on the top-right and click Run. The Run tool window with console will appear.

Running Express web app:

Starting with Express 4.0 file www.js in bin folder needs to be executed to start the app. When creating a new Express web application in WebStorm 8.0.2 or higher, the required Run/Debug configuration will be created automatically. Select configuration bin/www and click Run. Now when the app is running, you can open it in browser on localhost:<app’s server port number>.

Debugging Node.js app locally

Php vs node js

Nodejs Php Server

The same Run/Debug configuration can be used to debug your Node.js code.

The built-in Node.js debugger supports the latest features of V8 Debugger Protocol and allows you to step through the breakpoints, change values on the fly, evaluate expressions, and set watches.

Phpstorm Code Nodejs

Click the Debug button for the created Run/Debug configuration in the top right-hand corner of the IDE, from the Run menu or with the shortcut (Shift+F9 on Windows or Linux, Ctrl+D on Mac). A tool window with variables view, frames and watchers for your debug session will appear:

Debugging Node.js app that runs remotely

With Remote Node.js Debug configuration you can debug Node.js apps that are running remotely. You’ll be able to restart the debug session without restarting the app itself.
Select Remote Node.js Debug type when creating a new debug configuration, then specify the host you need to connect to and the port.

Phpstorm Nodejs

Now that the debug configuration is ready, select it from the drop-down list of configurations on the right and click Debug.

You’ll see the Debug tool window when the breakpoint is reached. You’ll be able to use full-featured debugger in the same way as if you were debugging your code locally.

Phpstorm Add Nodejs

Note: For remote debugging your app should be running with the parameter --debug=<port for debugging> or --debug-brk=<port for debugging>.

Phpstorm Nodejs Debugging

In Node.js you can’t access the port for debugging externally, which is why you need to configure a proxy or any other software that ensures port forwarding on the Node.js server (for an example of how to do that see stackoverflow).