# 通过 SSH 使用 Node.js

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

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

## 开始之前

Procedure:

1. 请确保在设置中已启用  JavaScript and TypeScript  捆绑插件。 按 `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` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))打开设置，然后选择  `插件` 。 在搜索字段中，键入  JavaScript 和 TypeScript 。 有关插件的更多信息，请参阅 [管理插件](managing-plugins.html)。

2. 按照 [从 JetBrains Marketplace 安装插件](managing-plugins.html#install_plugin_from_repo) 中所述，在   设置 | 插件   页面安装  Node.js ,  Node.js Remote Interpreter ,  JavaScript Debugger  和  FTP/SFTP/WebDAV Connectivity  插件。 插件仅在具有 Ultimate 订阅的 IntelliJ IDEA 中可用。

3. 按照 [创建 SSH 配置](create-ssh-configurations.html) 中所述，在目标远程主机上配置对  SSH  服务器的访问权限，并确保此服务器正在运行。

4. 确保您的项目源文件位于目标远程主机上。 这可以通过以下两种方式来实现：

* 请按照 [上传和下载文件](uploading-and-downloading-files.html)中所述将您的项目源文件上传到目标远程主机。

* 在您的本地机器上启用网络共享，并将项目文件夹挂载到远程主机上的目标目录。 您共享文件和文件夹的方式取决于您使用的操作系统。 有关详细信息，请参阅您的操作系统说明。

## 在可通过 SSH 访问的远程主机上配置 Node.js 运行时

通过 SSH 的 Node.js 运行时在   配置 Node.js 远程运行时   对话框中进行配置。 您可以从 [JavaScript 运行时](javascript-runtime.html) 页面（位于   设置   对话框中）打开此对话框，或者在稍后，当您 [创建或编辑 Node.js 运行/调试配置](#ws_node_ssh_create_run_debug_configuration) 以运行或调试您的应用程序时。

建议的方式是在   设置   对话框中配置远程 Node.js 运行时。 在这种情况下，您可以将该运行时及其关联的包管理器设置为项目默认。

直接在 Node.js 运行/调试配置中配置的远程 Node.js 运行时只能与该运行/调试配置一起使用。

Procedure:

1. 打开   设置   对话框（ `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` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))），然后转到  `语言与框架 | JavaScript 运行时` 。

2. 点击 ![浏览按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.general.ellipsis.svg) 字段旁的   Node.js 运行时  。

![添加运行时 - 浏览按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_interpreter_from_settings_browse_button.png)

3. 在包含所有当前已配置运行时列表的 [Node.js 运行时](node-js-interpreters.html) 对话框中，点击工具栏中的 !["添加"按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.general.add.svg)，然后在上下文菜单中选择   添加远程   .

![通过 SSH 配置 Node.js 运行时：添加远程](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_interpreter_from_settings_docker_add_remote.png)

4. 在打开的 [配置 Node.js 远程运行时对话框](configure-node-js-remote-interpreter.html) 中，选择   SSH  。

5. 选择要使用的 SSH 配置。

![通过 SSH 配置远程 Node.js 运行时：选择 SSH 配置](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_configure_remote_node_interpreter_ssh_select_ssh_configuration.png)

或者，点击 ![浏览按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.general.ellipsis.svg)，并按照 [创建 SSH 配置](create-ssh-configurations.html) 中所述创建新的 SSH 配置。

6. 点击   OK   返回到   Node.js 运行时   对话框，其中已将新运行时添加到列表。

![远程运行时对话框：通过 SSH 新建的 Node.js 运行时已添加到列表](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_node_configure_interpreter_remote_interpreters_dialog_ssh_node_added.png)

7. 要将新配置的运行时设置为项目默认，请在列表中选择它并点击   OK   以返回到   JavaScript 运行时   对话框。

每次您从   Node.js 运行时  列表中选择  `项目` 别名时，IntelliJ IDEA都会自动使用此解释器，例如在创建运行/调试配置时。

若要使用与新运行时关联的包管理器来管理项目依赖项，请将该包管理器设为项目默认。 要做到这一点，请在   包管理器  字段中指定包管理器的位置。

npm 可执行文件的默认位置是  `/usr/local/lib/node_modules/npm` 。

![通过 SSH 配置 Node.js 运行时：设置为默认项目解释器](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_interpreter_from_settings_ssh_default_project_interpreter_and_package_manager.png)

## 创建 Node.js 运行/调试配置

Procedure:

1. 前往  `运行 | 编辑配置` 。 在弹出的   编辑配置   对话框中，点击工具栏上的 ![添加新配置按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/调试配置](run-debug-configuration-node-js.html) 对话框打开。

2. 在   文件   字段中，指定启动应用程序的主文件路径（例如，  `bin/www`  对于 [Express](http://expressjs.com/) 应用程序）。

![Node.js 运行/调试配置：指定的 JavaScript 文件](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_ssh_configure_interpreter_run_configuration.png)

3. 如有必要，请按照 [运行和调试 Node.js 应用程序](running-and-debugging-node-js.html#ws_node_run_config_optionally)中描述的方式指定一些可选设置。

4. 在   Node.js 运行时   列表中，选择可通过 SSH 访问的相应远程 Node.js 运行时。

![创建 Node.js 运行配置：选择通过 SSH 解释器的远程 Node.js](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_ssh_run_configuration_select_interpreter.png)

或者，点击位于   Node.js 运行时   字段旁边的 ![浏览按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.general.ellipsis.svg)，并按照 [如上所述](#ws_node_ssh_configure_remote_interpreter_preferences_remote_interpreters_dialog) 配置远程 Node.js 运行时。

5. 将本地文件夹与远程主机上的文件夹进行映射。

1.

点击 ![浏览按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.actions.menu-open.svg) 旁边的   路径映射   字段或按 `Shift+Enter` (Windows), `Shift+Enter` (macOS), `Shift+Enter` (IntelliJ IDEA Classic (macOS)), `Shift+Enter` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `Shift+Enter` (Sublime Text (macOS)), `Shift+Enter` (Visual Studio), `Shift+Enter` (Visual Studio (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `Shift+Enter` (Eclipse (macOS))。

2.

在打开的 [编辑项目路径映射对话框](edit-project-path-mappings-dialog.html)中，点击工具栏上的 !["添加"按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.general.add.svg)。

![创建 Node.js 运行配置：添加映射](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_ssh_run_configuration_add_mapping.png)

3.

指定本地文件夹以及远程主机上对应文件夹的路径。 例如，您可以将项目文件夹映射到  `/home/opc` 。

![创建 Node.js 运行配置：已添加映射](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_ssh_run_configuration_mapping_added.png)

4.

当您点击   OK  时，您会返回   运行/调试配置  对话框，在   路径映射  字段中显示新的映射。

![创建 Node.js 运行配置：已添加映射显示](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ws_node_ssh_run_configuration_mapping_specified_final.png)

## 运行您的应用程序

Procedure:

* 在工具栏的   运行/调试配置   小部件列表中，选择新创建的   Node.js   配置，然后点击其旁边的 ![运行按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.run.run.svg)。

* 或者，创建一个   Node.js  运行/调试配置 [如上所述](#ws_node_ssh_create_run_debug_configuration)或修改现有的配置并在对话框中点击   运行  。

## 调试您的应用程序

Procedure:

1. 根据需要在 Node.js 代码中设置 [断点](using-breakpoints.html)。

2. 创建一个   Node.js   配置 [，如上所述](#ws_node_ssh_create_run_debug_configuration)，在工具栏的   选择运行/调试配置   列表中选择该配置，然后点击列表旁边的 ![调试按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.run.debug.svg)。

3. 按 [在本地随 Node.js 应用程序一起启动调试器](running-and-debugging-node-js.html#debugLocal)时的方式继续。

