# 运行/调试配置：连接到 Node.js/Chrome

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/idea/llms.txt).

> **TL;DR**
> 所需插件  :
>
>
>
> `JavaScript 和 TypeScript`  -  插件与 IntelliJ IDEA 捆绑在一起，并默认启用。
>
>
>
> `JavaScript Debugger` ，  `Node.js`  -  在   设置 | 插件   页面上安装插件。 插件仅在具有 Ultimate 订阅的 IntelliJ IDEA 中可用。

创建：  `运行 | 编辑配置 |`  ![添加新配置](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)  `| 附加到 Node.js/Chrome`

> **Warning:**
> 以下内容仅在   Node.js   插件 [已安装并启用](managing-plugins.html) 时有效。

在此对话框中，为已运行的 [Node.js](http://nodejs.org/) 应用程序创建调试配置。 这种方法使您可以在不重新启动 Node.js 服务器的情况下重新启动调试会话。

此外，请使用此配置来调试  main  进程和 [NW.js](https://nwjs.io/) 应用程序的后台和额外进程，参阅 [Run/Debug Configuration: NW.js](run-debug-configuration-node-webkit.html)。

使用此配置，您还可以 [调试 Chrome 扩展](debugging-javascript-in-chrome.html#ws_js_debug_chrome_extension)。

## 开始之前

Procedure:

1. 下载并安装 [Node.js](http://nodejs.org/#download)。

2. 在  `设置 | 插件`  中安装 Node.js 插件，如 [从 JetBrains Marketplace 安装插件](managing-plugins.html#install_plugin_from_repo) 中所述。

## 特定的 Attach to Node.js/Chrome 配置设置

|  条目  |  描述  |
| --- | --- |
|     主持人     |     在此字段中，指定应用程序运行的主机。     |
|     端口     |     在此字段中，指定启动 Node.js 进程以连接时传递给  `--inspect` 、  `--inspect-brk`  或  `--debug`  的端口。 从内置   终端  中的   调试器正在监听...  信息消息或控制正在运行的应用程序的 [Run](run-tool-window.html)工具窗口中复制此端口号。      ![从 Run 工具窗口或 Terminal 开始调试：信息消息](https://resources.jetbrains.com/help/img/idea/2026.3/ws_node_debug_attach_from_terminal_info_message.png)   > **Warning:** > 请确保此端口不同于应用程序运行所用的端口。 默认端口为 9229。    |
|     自动重新连接     |     选中此复选框以启用 IntelliJ IDEA 内置调试器在应用程序代码更改后重新附加到正在运行的 Node.js 进程。 这样，您可以调试使用 [nodemon 实用程序](https://nodemon.io/) 的 Node.js 应用程序，该实用程序会在代码更新时自动重新加载 Node.js 进程。 如需更多信息，请参阅 [调试使用 nodemon 的应用程序](running-and-debugging-node-js.html#nodemon)。     |
|     本地文件的远程 URL     |     在此区域，指定项目文件夹的远程路径。 如果正在运行的应用程序的根文件夹与您的 IntelliJ IDEA 项目根文件夹名称不同，这会很有帮助。 在以下示例中，IntelliJ IDEA 项目根文件夹  `/Users/WsProjects/express`  已映射到服务器上的  `/usr/src/app` 。      ![指定本地文件的远程 URL](https://resources.jetbrains.com/help/img/idea/2026.3/workspace.xml` 。     |

## 工具栏

运行/调试配置的树状视图包含一个工具栏，可帮助您管理 project 中可用的配置，以及调整默认配置模板。

|  条目  |  快捷键  |  描述  |
| --- | --- | --- |
|  !["添加"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)  |  `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS))  |  创建运行/调试配置。  |
|  !["移除"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)  |  `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS))  |  删除选定的运行/调试配置。 请注意，您不能删除默认配置。  |
|  ![复制](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.copy.svg)  |  `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Meta+D` (Emacs), `Ctrl+Shift+D` (Sublime Text), `⌘ ⇧ D` (Sublime Text (macOS)), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Eclipse), `Ctrl+D` (Eclipse (macOS))  |  创建选定运行/调试配置的副本。 请注意，将会创建默认配置的副本。  |
|  ![保存配置](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.save.svg)  |  |  仅当选择 [临时配置](null)时，才会显示该按钮。 点击此按钮以将临时配置保存为永久配置。  |
|  ![移动到新文件夹 / 创建新文件夹](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.actions.newFolder.svg)  |  |     移动到新文件夹 / 创建新文件夹。 您可以通过 [将它们放入文件夹](run-debug-configuration.html#config-folders)来对运行/调试配置进行分组。       要创建文件夹，请选择某个类别中的配置，点击 ![文件夹](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.nodes.folder.svg)，并指定文件夹名称。 如果只有一个类别处于焦点状态，则会创建一个空文件夹。       然后，若要将配置移入文件夹、在文件夹之间移动或移出文件夹，请使用拖放操作或 ![上移](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.moveUp.svg) 和 ![下移](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.moveDown.svg) 按钮。       要移除分组，请选择一个文件夹，然后点击 ![移除配置](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)。     |
|  ![排序配置](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.objectBrowser.sortAlphabetically.svg)  |  |  点击此按钮以按字母顺序对配置进行排序。  |

## 启动前

在此区域，您可以指定在启动所选的运行/调试配置之前需要执行的任务。 任务将按其在列表中出现的顺序执行。

|  条目  |  快捷键  |  描述  |
| --- | --- | --- |
|  !["添加"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)  |  `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS))  |     点击此图标以添加以下可用任务之一：        * 启动 Web 浏览器‍™™™™™™™‍ ：选择此选项以启动浏览器。 在打开的对话框中，选择浏览器类型并提供起始 URL。 此外，请指定是否要使用 JavaScript 调试器启动浏览器。    * 运行外部工具 ：选择运行外部应用。 在打开的对话框中，选择您想要运行的一个或多个应用程序。 如果它在 IntelliJ IDEA 中尚未定义，请添加其定义。 如需更多信息，请参阅 [外部工具](configuring-third-party-tools.html) 和 [外部工具设置](settings-tools-external-tools.html)。    * 运行另一个配置 ：选择执行另一个运行/调试配置，并等待其完成后再启动当前配置。 如果您想并行运行多个配置，请使用 [compound run/debug configuration](run-debug-multiple.html#compound-configs)。    * 构建 ：选择编译指定的模块。 [Build Module命令](compiling-applications.html#compile_module) 将会被执行。 如果在编译过程中发生错误，IntelliJ IDEA 将不会尝试启动运行/调试配置。    * 构建项目 ：选择编译整个项目。 [Build Project 命令](compiling-applications.html#compile_module) 将被执行。 如果在编译过程中发生错误，IntelliJ IDEA 将不会尝试启动运行/调试配置。    * 构建，不进行错误检查 ：与 构建 选项相同，但 IntelliJ IDEA 将会尝试启动运行/调试配置，而不考虑编译结果。    * 构建制品 ：选择此选项以构建一个或多个 [构件](working-with-artifacts.html)。 在打开的对话框中，选择应构建的 artifact。    * 运行远程外部工具 ：添加一个 [远程 SSH 外部工具](settings-tools-remote-ssh-external-tools.html)。    * 运行 Grunt 任务 ：选择此选项以运行 Grunt 任务。 在打开的 Grunt 任务 对话框中，指定定义所需任务的 `Gruntfile.js` ，选择要执行的任务，并指定传递给 Grunt 工具的参数。 指定 Node.js 解释器的位置、传递给它的参数以及 grunt-cli 包的路径。    * 运行 Gulp 任务 ：选择此选项以运行 Gulp 任务。 在打开的 Gulp 任务 对话框中，请指定定义所需任务的 `Gulpfile.js` ，选择要执行的任务，并指定传递给 Gulp 工具的参数。 指定 Node.js 运行时的位置、要传递给它的参数，以及 gulp 包的路径。    * 运行 Maven 目标 ：选择此选项以 [运行一个 Maven 目标](work-with-maven-goals.html)。 在打开的对话框中，选择要运行的目标。    * 运行 npm 脚本 ：选择此选项以执行 npm script。 在打开的 npm 脚本 对话框中，指定 [npm 运行/调试配置设置](null)。    * 编译 TypeScript ：选择运行内置的 TypeScript 编译器，从而确保您对 TypeScript 代码所做的所有更改都反映在生成的 JavaScript 文件中。 在打开的 TypeScript 编译设置 对话框中，选择或清除 检查错误 复选框，以配置在检测到任何错误时编译器的行为： * 如果选中 检查错误 复选框，编译器将显示所有错误，运行配置将不会启动。 * 如果取消选中 检查错误 复选框，编译器将显示所有检测到的错误，但仍会启动运行配置。    * 生成 CoffeeScript 源代码映射图 ：选择此选项以为您的 [CoffeeScript](coffeescript.html) 源文件生成源代码映射。 在打开的对话框中，指定您的 CoffeeScript 源文件所在的位置。    * 运行 Rake 任务 ：添加一个 [Rake 任务](null)，以便在运行或调试之前执行。 要选择 Rake 任务，请点击浏览按钮 ![浏览按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.general.ellipsis.svg)，然后从可用任务列表中选择所需的任务。 请注意，此处可使用 [代码补全](auto-completing-code.html)。 ![Rake 任务的代码补全](https://resources.jetbrains.com/help/img/idea/2026.3/runConfigRakeTask.png)    * 运行 JRuby 编译器 ：选择此选项，以使用指定的目标路径、编译器进程堆大小和命令行形参（如果有）执行 JRuby 编译器。    |
|  !["移除"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)  |  `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS))  |  点击此图标以从列表中删除所选任务。  |
|  ![编辑](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.edit.svg)  |  `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS))  |  点击此图标以编辑所选任务。 在打开的对话框中进行必要的更改。  |
|     ![方法 up](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.moveUp.svg)       ![方法 down](https://resources.jetbrains.com/help/img/idea/2026.3/调试配置：Node.js](run-debug-configuration-node-js.html)

