# Running and debugging Node.js

> **TL;DR**
> Required plugins:
>
>
>
> `JavaScript and TypeScript` -    the plugin is bundled with IntelliJ IDEA and enabled by default.
>
>
>
> `JavaScript Debugger`, `Node.js` -    install the plugins on the Settings | Plugins page, tab Marketplace.     The plugins are available only in IntelliJ IDEA with the Ultimate subscription.

IntelliJ IDEA helps you run and debug your Node.js applications. You can debug applications that are started from IntelliJ IDEA as well as attach to already running applications.

## Before you start

Procedure:

1. Make sure the  JavaScript and TypeScript plugin is enabled in the settings.  Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Plugins`.  Click the Installed tab. In the search field, type JavaScript and TypeScript. For more information about plugins, refer to [Managing plugins](managing-plugins.html).

2. Install the Node.js and JavaScript Debugger plugins on the Settings | Plugins page, tab Marketplace, as described in [Installing plugins from
JetBrains Marketplace](managing-plugins.html#install_plugin_from_repo).     The plugins are available only in IntelliJ IDEA with the Ultimate subscription.

## Run a Node.js application

IntelliJ IDEA runs Node.js applications according to a run configuration of the type Node.js. IntelliJ IDEA also uses this configuration to [start the debugger together with Node.js applications](#debugLocal).

Procedure: Create a Node.js run/debug configuration

1. Go to `Run | Edit Configurations`. Alternatively, select Edit Configurations from the Run widget on the toolbar.

![Open the Edit Configurations dialog](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_run_config_create.png)

In the Edit Configurations dialog that opens,    click the Add button (![the Add button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg)) on the toolbar and select Node.js from the list.  The [Run/Debug Configuration: Node.js](run-debug-configuration-node-js.html) dialog opens.

2. Specify the Node.js runtime to use.

If you choose the Project alias, IntelliJ IDEA will automatically use the project default interpreter from the Node runtime field on the [JavaScript Runtime](javascript-runtime.html) page . In most cases, IntelliJ IDEA detects the project default runtime and fills in the field itself.

You can also choose another configured local or remote interpreter or click ![the Browse button](https://resources.jetbrains.com/help/img/idea/2026.2/app.general.ellipsis.svg) and configure a new one.

3. In the File field, specify the path to the main file of the application that starts it (for example, `bin/www` for [Express](http://expressjs.com/) applications).

4. Optionally:

* Specify the Node parameters that customize the start of Node.js. For example, you may want to enable an experimental Node.js feature or pass another option. For more information, refer to the [Node.js official website](https://nodejs.org/api/cli.html).

* In the Application parameters field, specify the Node.js-specific arguments to be passed to the application on start through the [process.argv](http://nodejs.org/docs/latest/api/process.html#process.argv) array.

* To open the application in the browser automatically, configure a before-launch task. Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.general.arrowRight.svg) to expand the Before launch area, click ![the Add button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg), and select Launch Web Browser from the list. In the dialog that opens, specify the URL of the application starting page, for example, `localhost:3000` for Express applications, and the browser to use. ![Before-launch task: open browser](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_run_configuration_open_browser_before_launch_task.png)

Procedure: Run an application

* [Create a run/debug
configuration as
described above](#Node.js_run) or modify an existing one and click  Run in the dialog.

* Alternatively,   select the newly created run configuration from the list on the main toolbar and click ![the Run button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.run.run.svg).

![Start an app with a run/debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_run_app_with_rc.png)

The application starts, and the [Run tool window](run-tool-window.html) opens showing the application output.

If you are using a logging tool like [morgan](https://www.npmjs.com/package/morgan) in your application and this tool writes logs to a file, you can see these logs in the Console tab of the Run tool window.

Procedure: Manage logs when running a Node.js application

1. Create a Node.js run/debug configuration [as described above](#Node.js_run) and go to the Logs tab.

2. Click ![the Add button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) next to the Log files to be shown in console field which lists the available log files (if any).

3. In the Edit Log Files Aliases  dialog that opens, type the alias name to show in the list of log entries and specify the location of the log file. Select whether you want to show all files that this pattern covers or only the last one.

4. Click OK to return to Node.js Run/Debug Configuration dialog, where the new log file is added to the list. Select the Is Active checkbox next to it. To skip the previous content, select the Skip Content checkbox.

5. Optionally:

* To enable saving the Process Console output to a log file, select the Save console output to file checkbox and specify the file location.

* Choose when you want the Process Console shown.

## Debug a Node.js application

IntelliJ IDEA makes it easier to debug Node.js applications. You can put breakpoints right in your JavaScript or TypeScript code so you no longer need any `debugger` and `console.log()` statements. You can do many things that will help you explore the code and understand where the bug is. In the Debug tool window, you can view the call stack and the variables in their current state, evaluate expressions in the editor, and step through the code.

You can initiate a debugging session in two ways:

* Start the debugger together with your application using a Node.js run/debug configuration.

* Attach the debugger to an already running application. In this case, your application is already running in the [debug mode](https://nodejs.org/en/docs/guides/debugging-getting-started/) and IntelliJ IDEA attaches to a running process. IntelliJ IDEA recognizes `--inspect`, `--inspect-brk`, and now deprecated `--debug` flags so you can make any application accessible for debugging. To debug a running application, use an Attach to Node.js/Chrome configuration.

With IntelliJ IDEA, you can also debug Node.js applications that are running in [Vagrant boxes](vagrant-support.html), in [Docker containers](docker.html), or on remote hosts accessible via [various transfer protocols](configuring-synchronization-with-a-remote-host.html) or via SSH.

### Start the debugger together with a Node.js application on your computer

![Start and debug a Node.js Express app](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_debug-local.animated.gif)

Procedure:

1. Set the [breakpoints](using-breakpoints.html) in the code where necessary.

2. Create a Node.js run/debug configuration [as described above](#Node.js_run).

To open the application in the browser automatically, configure a before-launch task. Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.general.arrowRight.svg) to expand the Before launch area, click ![the Add button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg), and select Launch Web Browser from the list. In the dialog that opens, specify the URL of the application starting page, for example, `localhost:3000` for Express applications, and the browser to use.

![Before-launch task: open browser](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_run_configuration_open_browser_before_launch_task.png)

> **Tip:**
> If necessary, IntelliJ IDEA can generate a JavaScript Debug configuration and start it automatically together with the Node.js configuration  as described in [Debugging the server- and the client-side code](node-debug-server-client.html).

3. From the Run widget list on the toolbar, select the newly created Node.js configuration and click ![the Debug button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.run.debug.svg) next to it.

![Start a Node.js  debugging session with a run/debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_debug_app_with_rc.png)

The [Debug tool window](debug-tool-window.html) opens.

4. Perform the steps that will trigger the execution of the code with the breakpoints. For example, navigate from the starting page of your application to another page in the browser.

5. Switch to IntelliJ IDEA, where the controls of the Debug tool window are now enabled.  Proceed with the debugging session — [step through the breakpoints](stepping-through-the-program.html), switch between frames, change values on-the-fly, [examine a suspended program](examining-suspended-program.html), [evaluate expressions](examining-suspended-program.html#evaluating-expressions), and [set watches](examining-suspended-program.html#watches).

### Debug a running Node.js application

With IntelliJ IDEA, you can debug an application that is already running in the development mode, which means that the application was launched with the `--inspect` or `--inspect -brk` flag. A debugging session is initiated through an Attach to Node.js/Chrome configuration and uses the [Chrome
Debugging Protocol](https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js).

#### Start the debugger from the Run or Debug tool window or from the built-in Terminal

If an application was started with the `--inspect` or `--inspect-brk` flag, you can start a debugging session from the built-in Terminal, from the Run tool window, or from the Debug tool window.

![Attach the debugger to a running app from the Run tool windowl](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_debug_attach_from_run_tw.animated.gif)

Procedure:

1. Set the [breakpoints](using-breakpoints.html) as necessary.

2. Run your application with an `--inspect` or `--inspect-brk` flag. You can do that in several ways, for example:

* In your `package.json`, click ![the Run button](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.run.run.svg) in the gutter next to the script with the `--inspect` or `--inspect -brk` flag and select Run '<script name>'. For more information, refer to [Run scripts](installing-and-removing-external-software-using-node-package-manager.html#ws_npm_running_npm_scripts). ![Launch an app in the debug mode: launch a script](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_attach_debugger_run_npm_script_select_action.png)

* Open your command-line shell or the embedded Terminal (`Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS))) and, type: `node --inspect-brk <path to the starting page of your application relative to the project root>`

3. The Terminal, the Run tool window, or the Console tab of the Debug  tool window shows an information message `Debugger listening <host>:<port>`, the default port is `9229`. To start debugging, hold `Ctrl+Shift` (Windows), `Ctrl+Shift` (macOS), `Ctrl+Shift` (IntelliJ IDEA Classic (macOS)), `Ctrl+Shift` (macOS System Shortcuts), `Ctrl+Shift` (XWin), `Ctrl+Shift` (GNOME), `Ctrl+Shift` (KDE), `Ctrl+Shift` (Emacs), `Ctrl+Shift` (Sublime Text), `Ctrl+Shift` (Sublime Text (macOS)), `Ctrl+Shift` (NetBeans), `Ctrl+Shift` (Visual Studio), `Ctrl+Shift` (Visual Studio (macOS)), `Ctrl+Shift` (Eclipse), `Ctrl+Shift` (Eclipse (macOS)) and click the link.

IntelliJ IDEA starts a debugging session with an automatically generated Attach to Node.js/Chrome configuration.    Perform the steps that will trigger the execution of the code with the breakpoints. For example, navigate from the starting page of your application to another page in the browser.

> **Note:**
> Alternatively, copy the port number from the `Debugger listening <host>:<port>` message and paste it later in the [Attach to Node.js/Chrome
> configuration](#ws_debug_node_remote_inspect_mappings).

#### Attach the debugger to a running app via a run/debug configuration

Procedure:

1. Run your application with an `--inspect` or `--inspect-brk` flag, [as described above](#ws_node_run_with_inspect).

2. Set the [breakpoints](using-breakpoints.html) as necessary.

3. Go to `Run | Edit Configurations` in the main menu, then click ![Add New Configuration](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) in the Edit Configuration dialog that opens, and select Attach to Node.js/Chrome from the list.

![Select the Attach to Node.js /Chrome configuration type](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_debug_remote_chrome_create_attach_run_config.png)

The [Run/Debug Configuration: Attach to Node.js/Chrome](run-debug-configuration-node-js-remote-debug.html) dialog opens.

4. Specify the host where the target application is running and the port passed to `--inspect` or `--inspect-brk` when starting the Node.js process to connect to.

![Attach to Node/Chrome run/debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_debug_attach_to_app_run_config.png)

Copy the port number from the information message `Debugger listening <host>:<port>` in the Terminal tool window or in the [Run tool window](run-tool-window.html) that controls the running application.

![Start debugging from Run tool window or Terminal: information message](https://resources.jetbrains.com/help/img/idea/2026.2/ws_node_debug_attach_from_terminal_info_message.png)

> **Warning:**
> Make sure this port is different from the port on which the application is running. The default port is 9229.

> **Tip:**
> Optionally: specify the remote paths for the project folders in the Remote URLs of local files  area. This is helpful if the root folder of the running application is different from the name of you IntelliJ IDEA project root folder.

5. From the Run widget list on the toolbar, select the newly created Attach to Node.js/Chrome configuration and click ![the Debug button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.run.debug.svg) next to it.  The [Debug tool window](debug-tool-window.html) opens.

6. Perform the actions that will trigger the code at the breakpoint. Control over the debugging session returns to IntelliJ IDEA.

7. Switch to IntelliJ IDEA. In the Debug tool window, [step through the breakpoints](stepping-through-the-program.html), switch between frames, change values on-the-fly, [examine a suspended program](examining-suspended-program.html),  [evaluate expressions](examining-suspended-program.html#evaluating-expressions) , and  [set watches](examining-suspended-program.html#watches).

### Debug a Node.js application that uses nodemon

> **Tip:**
> For more information, refer to [Running and debugging scripts](installing-and-removing-external-software-using-node-package-manager.html#ws_npm_running_npm_scripts).

The IntelliJ IDEA built-in debugger can automatically reconnect to running Node.js processes.  This lets you debug Node.js applications that use the [nodemon utility](https://nodemon.io/), which automatically reloads your Node.js process when the code is updated.

To debug such application, you need to start it in the debug mode (with the `--inspect` or `--inspect-brk` flag) and then connect to it using the [Attach to a Node.js/Chrome](#node_debugging_overview) debug configuration with the Reconnect Automatically option on.

Procedure: Install nodemon

* In your command-line shell or in the embedded Terminal (`Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS))) , type `npm install --save-dev nodemon` or `yarn add nodemon --dev` to install nodemon as a development dependency.

Procedure: Start an application with nodemon in the debug mode

* Create and run the following `npm debug` script:

```SHELL
"debug": "nodemon --inspect <path_to_the_file_that_starts_your_application>
```

For more information, refer to [Running and debugging scripts](installing-and-removing-external-software-using-node-package-manager.html#ws_npm_running_npm_scripts).

* Alternatively, pass the `inspect` flag through a Node.js run/debug configuration [as described above](#ws_node_run_config_optionally).

Procedure: Debug an application

1. Set the [breakpoints](using-breakpoints.html) in your code as necessary.

2. Create a new Attach to a Node.js/Chrome configuration as described in [Debugging a running Node.js application](#node_debugging_overview) and select the Reconnect automatically checkbox.

![Attach no Node.js run configuration: select the Reconnect automatically checkbox](https://resources.jetbrains.com/help/img/idea/2026.2/ws_run_config_attach_to_node_reconnect.png)

Usually, you don’t need to change the port in the configuration `9229` because it’s the default port the debugger is listening on. But you can double-check what port is used in the message logged when you run the app in the debug mode.

![Node.js application with  nodemon running in the debug mode: check the port](https://resources.jetbrains.com/help/img/idea/2026.2/ws_debug_port_nodemon.png)

3. From the Run widget list on the toolbar, select the newly created Attach to Node.js/Chrome configuration and click ![the Debug button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.run.debug.svg) next to it.  The debugger stops at the breakpoints that you put in your code in IntelliJ IDEA.

Now, every time you make any changes to the code and save them `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+S` (NetBeans), `Ctrl+Shift+S` (Visual Studio), `⌘ ⇧ S` (Visual Studio (macOS)), `Ctrl+S` (Eclipse), `⌘ S` (Eclipse (macOS)), nodemon will automatically reload the application, and the debugger will automatically re-attach to the restarted process.

## See also

### Procedures

[Node.js](developing-node-js-applications.html) [Run applications](running-applications.html) [Debug code](debugging-code.html)  [Debug tool window](debug-tool-window.html)

### Reference

[Run/Debug Configuration: Node.js](run-debug-configuration-node-js.html) [Run/Debug Configuration: Attach to Node.js/Chrome](run-debug-configuration-node-js-remote-debug.html) [Run tool window](run-tool-window.html)

