Run/debug configurations运行/调试配置
WebStorm uses run/debug configurations to run, debug, and test your code. WebStorm使用运行/调试配置来运行、调试和测试代码。Each configuration is a named set of run/debug startup properties.每个配置都是一组命名的运行/调试启动属性。
If the Navigation bar is visible ( ), you can access all available run/debug configurations from the selector on the toolbar.如果导航栏可见(“查看”|“外观”|“导航栏”),则可以从工具栏上的选择器访问所有可用的运行/调试配置。
Run/debug configurations can be created as:运行/调试配置可以创建为:
-
Temporary暂时的–created every time you select每次从上下文菜单中选择“运行<项目名称>”时创建。 from the context menu.To call the context menu, right-click an object or an area.要调用关联菜单,请在对象或区域上单击鼠标右键。The maximum number of temporary configurations is 5.临时配置的最大数量为5。The older ones are automatically deleted when new ones are added.旧的会在添加新的时自动删除。If necessary, you can increase this limit in如有必要,您可以在“设置/首选项”|“高级设置”|“IDE”|“临时运行/调试配置限制”中增加此限制。 . -
Permanent永久的–created explicitly from a template or by saving a temporary configuration.通过模板或保存临时配置显式创建。Permanent configurations remain as part of your project until you remove them.永久性配置保留为项目的一部分,直到您删除它们。
So whenever you run/debug or test your code, WebStorm either uses an existing permanent run/debug configuration or creates a new temporary one.因此,无论何时运行/调试或测试代码,WebStorm要么使用现有的永久运行/调试配置,要么创建新的临时配置。
Permanent configurations have opaque icons while the icons of temporary configurations are semi-transparent.永久配置的图标不透明,而临时配置的图标是半透明的。

Create permanent run/debug configurations创建永久运行/调试配置
WebStorm provides the following ways to create a permanent run/debug configuration:WebStorm提供以下方法来创建永久运行/调试配置:
-
Save a temporary run/debug configuration as permanent.将临时运行/调试配置另存为永久配置。 -
Create from a template or copy an existing configuration.从模板创建或复制现有配置。
Save a temporary configuration as permanent将临时配置另存为永久配置
-
Select a temporary configuration in the run/debug configuration switcher and then click Save Configuration.在运行/调试配置切换器中选择临时配置,然后单击“保存配置”。 -
Alternatively, select a temporary configuration in the Run/debug configurations dialog and click或者,在“运行/调试配置”对话框中选择一个临时配置,然后单击工具栏上的on the toolbar.
。
-
Open the Edit Configurations dialog ( ), select the temporary configuration to save, and click打开“编辑配置”对话框(“运行”|“编辑配置”),选择要保存的临时配置,然后单击工具栏上的on the toolbar.
。
WebStorm provides run/debug configuration templates for different languages, tools, and frameworks. WebStorm为不同的语言、工具和框架提供运行/调试配置模板。The list of available templates varies depending on the installed/bundled plugins.可用模板的列表因安装/捆绑的插件而异。
Create a run/debug configuration from a template从模板创建运行/调试配置
-
Open the Run/Debug Configuration dialog in one of the following ways:通过以下方式之一打开“运行/调试配置”对话框:-
Select从主菜单中选择“运行”|“编辑配置”。 from the main menu. -
With the Navigation bar visible ( ), choose from the run/debug configuration selector.在导航栏可见的情况下(“查看”|“外观”|“导航栏”),从运行/调试配置选择器中选择“编辑配置”。 -
Press Alt+Shift+F10, then press 0 or select the configuration from the popup and press F4.按Alt+Shift+F10,然后按0或从弹出窗口中选择配置并按F4。
-
-
In the Run/Debug Configuration dialog, click在“运行/调试配置”对话框中,单击工具栏上的on the toolbar or press Alt+Insert.
或按Alt+Insert。
The list shows the run/debug configuration templates.该列表显示运行/调试配置模板。Select the desired template.选择所需的模板。If you are not sure which template to choose, refer to Run/debug configurations dialog for more information on particular templates.如果不确定要选择哪个模板,请参阅“运行/调试配置”对话框以了解有关特定模板的更多信息。 -
Specify the run/debug configuration name in the Name field.在名称字段中指定运行/调试配置名称。This name will be shown in the list of the available run/debug configurations.此名称将显示在可用运行/调试配置列表中。 -
Select Allow parallel run if you want to allow multiple instances of the configuration to run at the same time.如果要允许配置的多个实例同时运行,请选择“允许并行运行”。If this option is disabled, attempting to re-run the configuration will terminate the active session.如果禁用此选项,尝试重新运行配置将终止活动会话。 -
Set the run/debug configuration parameters.设置运行/调试配置参数。The list of mandatory and optional parameters may vary depending on the selected run/debug configuration type.强制参数和可选参数的列表可能因所选的运行/调试配置类型而异。For the detailed description of the selected template, see the respective section of run/debug configurations reference.有关所选模板的详细说明,请参阅运行/调试配置参考的相应部分。 -
In the Before launch section, define whether you want to perform any specific actions before launching the application, for example, execute some tools or scripts prior to launching the run/debug configuration.在“启动前”部分中,定义是否要在启动应用程序之前执行任何特定操作,例如,在启动运行/调试配置之前执行一些工具或脚本。For information on particular Before launch activities, refer to Before launch有关特定“启动前”活动的信息,请参阅启动前。 -
Apply the changes and close the dialog.应用更改并关闭对话框。
Share run/debug configurations共享运行/调试配置
If you are working in a team, you might want to share your run/debug configurations so that your teammates could run the application using the same configuration or enable them to remotely attach to the process you are running.如果您在团队中工作,您可能希望共享您的运行/调试配置,以便您的团队成员可以使用相同的配置运行应用程序,或使他们能够远程连接到您正在运行的进程。
For these purposes, WebStorm provides a mechanism to store your run/debug configurations as project files and share them through VCS. 出于这些目的,WebStorm提供了一种将运行/调试配置存储为项目文件并通过VCS共享的机制。The same mechanism can also be used when you want to send your configuration as a file to someone else. 当您希望将配置作为文件发送给其他人时,也可以使用相同的机制。This saves a lot of time as run/debug configurations sometimes get sophisticated, and keeping them in sync manually would be tedious and error-prone.这节省了大量时间,因为运行/调试配置有时会变得复杂,手动保持它们的同步将非常繁琐且容易出错。
-
From the main menu, select从主菜单中,选择“运行”|“编辑配置”。 .Alternatively, press Alt+Shift+F10, then 0.或者,按Alt+Shift+F10,然后按0。 -
Select the run/debug configuration you want to share, enable the Store as project file option, and specify the location where the configuration file will be stored.选择要共享的运行/调试配置,启用“存储为项目文件”选项,并指定存储配置文件的位置。If compatibility with WebStorm 2019.3 and earlier is required, store the file in the default location.如果需要与WebStorm 2019.3及更早版本兼容,请将文件存储在默认位置。 -
(Optional) If the .idea directory is added to VCS ignored files, the .idea/runConfigurations subfolder will be ignored, too.(可选)如果将.idea目录添加到VCS忽略的文件中,则也将忽略.idea/runConfigurations子文件夹。If you use Git for your project, you can share .idea/runConfigurations only and leave .idea ignored by modifying .gitignore as follows:如果在项目中使用Git,则只能共享.idea/runConfigurations,并通过修改.gitignore
将.idea忽略,如下所示:/.idea/* !/.idea/runConfigurations
Run/debug configuration templates运行/调试配置模板
Each type of run/debug configuration is a template that you can edit, so the next time you create a new configuration of that type, its parameters already have the desired values.每种类型的运行/调试配置都是可以编辑的模板,因此下次创建该类型的新配置时,其参数已经具有所需的值。
Configure the default values for a template配置模板的默认值
-
From the main menu, select从主菜单中,选择“运行”|“编辑配置”。 .Alternatively, press Alt+Shift+F10, then 0.或者,按Alt+Shift+F10,然后按0。 -
In the left-hand pane of the run/debug configuration dialog, click Edit configuration templates.在“运行/调试配置”对话框的左侧窗格中,单击“编辑配置模板”。 -
In the Run/Debug Configuration Templates dialog that opens, select a configuration type.在打开的“运行/调试配置模板”对话框中,选择配置类型。 -
Specify the desired default parameters and click OK to save the template.指定所需的默认参数,然后单击“确定”保存模板。
Alternatively, select 或者,从主菜单中选择“文件”|“新建项目设置”|“运行配置模板”,或者按Shift键两次,然后开始键入 from the main menu or press Shift twice and start typing Templates for New Projects
.Templates for New Projects
。

In the dialog that opens, select the configuration type and specify the desired parameters in the right-hand pane.在打开的对话框中,选择配置类型并在右侧窗格中指定所需的参数。
Compound run/debug configurations复合运行/调试配置
A Compound run configuration lets you launch several run/debug configurations at a time. “复合”运行配置允许您一次启动多个运行/调试配置。This may happen when you need to debug the client-side code and the server-side code simultaneously.当您需要同时调试客户端代码和服务器端代码时,可能会发生这种情况。
When you launch a Compound configuration all the configurations in it are started in the same mode, either Run or Debug. 启动复合配置时,其中的所有配置都以相同模式启动(运行或调试)。Therefore, to start an application in the development mode before debugging its client- and server-sides, use an npm script or create a separate run configuration.因此,要在调试客户端和服务器端之前以开发模式启动应用程序,请使用npm脚本或创建单独的运行配置。

Create a compound run/debug configuration创建复合运行/调试配置
-
From the main menu, select从主菜单中,选择“运行”|“编辑配置”。 .Alternatively, press Alt+Shift+F10, then 0.或者,按Alt+Shift+F10,然后按0。 -
In the Run/Debug Configurations dialog, click在“运行/调试配置”对话框中,单击or press Alt+Insert, then select Compound.
或按Alt+Insert,然后选择“复合”。
-
Specify the run/debug configuration name in the Name field.在名称字段中指定运行/调试配置名称。This name will be shown in the list of the available run/debug configurations.此名称将显示在可用运行/调试配置列表中。 -
Select Store as project file to make this run/debug configuration available to other team members.选择“存储为项目文件”以使此运行/调试配置可供其他团队成员使用。 -
To include a new run/debug configuration into the compound configuration, click Add要将新的运行/调试配置包括到复合配置中,请单击“添加”and select the desired one from the list.
并从列表中选择所需的配置。
-
Apply the changes.
Run/debug configuration folders运行/调试配置文件夹
When there are many run/debug configurations of the same type, you can group them in folders so they become easier to distinguish visually.当有许多相同类型的运行/调试配置时,您可以将它们分组到文件夹中,以便在视觉上更容易区分。
Once grouped, the run/debug configurations appear in the list under the corresponding folders.分组后,运行/调试配置将显示在相应文件夹下的列表中。

Create a folder for run/debug configurations为运行/调试配置创建文件夹
-
From the main menu, select从主菜单中,选择“运行”|“编辑配置”。 .Alternatively, press Alt+Shift+F10, then 0.或者,按Alt+Shift+F10,然后按0。 -
In the Run/Debug Configurations dialog, select a configuration type and click在“运行/调试配置”对话框中,选择配置类型并单击工具栏上的on the toolbar.
。
A new empty folder for the selected type is created.将为所选类型创建一个新的空文件夹。 -
Specify the folder name in the text field to the right or accept the default name.在右侧的文本字段中指定文件夹名称或接受默认名称。 -
Select the desired run/debug configurations and move them under the target folder.选择所需的运行/调试配置,并将其移动到目标文件夹下。 -
Apply the changes.应用更改。If a folder is empty, it will not be saved.如果文件夹为空,则不会保存该文件夹。
When you no longer need a folder, you can delete it Delete. 当您不再需要文件夹时,可以用Delete将其删除。The run/debug configurations grouped under this folder will be moved under the root of the corresponding run/debug configuration type.此文件夹下分组的运行/调试配置将移动到相应运行/调试配置类型的根目录下。
Run/Debug configurations in the Services tool window在服务工具窗口中运行/调试配置
You can manage multiple run/debug configurations in the Services tool window. 您可以在“服务”工具窗口中管理多个运行/调试配置。For example, you can start, pause, and stop several applications, track their status, and examine application-specific details.例如,您可以启动、暂停和停止多个应用程序,跟踪它们的状态,并检查特定于应用程序的详细信息。
Add Run/Debug configurations to the Services window将运行/调试配置添加到“服务”窗口
-
Select从主菜单中选择“查看”|“工具窗口”|“服务”或按Alt+8。 from the main menu or press Alt+8. -
In the Services tool window, click Add service, then select Run Configuration Type.在“服务”工具窗口中,单击“添加服务”,然后选择“运行配置类型”。 -
Select a run/debug configuration type from the list to add all configurations of this type to the window.从列表中选择运行/调试配置类型,以将此类型的所有配置添加到窗口中。Note that the tool window will only display the configuration types for which you have created one or more configurations.请注意,工具窗口将仅显示您为其创建了一个或多个配置的配置类型。