NestJS - 使用监视模式进行调试 - 端口已在使用中

问题描述 投票:0回答:1

我的 NestJS 应用程序中的调试出现问题。

我的设置:

  • Windows + WSL2
  • PhpStorm
  • Docker
  • 节点18.18
  • NestJS 10.3.0

package.json

"start:debug": "nest start --debug=0.0.0.0:9229 --watch"

PhpStorm 运行/调试配置

  • 我运行命令
    npm run start:debug
    ,我的应用程序正常旋转
  • 我在 PhpStorm 中启动调试 (Shift + F9),它连接到我的应用程序,我看到“已连接调试器”。在终端中。不过需要一段时间(比如 30 秒)。
  • 我对代码进行了一些更改,我的应用程序会自动重建(因为
    --watch
  • 我在终端中看到
    Starting inspector on 0.0.0.0:9229 failed: address already in use
    ,调试器无法再次连接。

使其再次工作的唯一方法是按 Ctrl + C 停止整个过程并再次运行。

有没有办法以这种方式进行设置,以便我在更改任何内容后不需要重新启动应用程序?我在 NestJS 文档中没有看到任何

--watch
--debug
不能一起工作的内容。

debugging nestjs phpstorm webstorm
1个回答
0
投票

应该在dockerfile中安装ps cmd

# Install procps which includes the 'ps' command
# RUN apt-get update && apt-get install -y procps
© www.soinside.com 2019 - 2024. All rights reserved.