简体   繁体   English

如何在调试模式下使用node.js ts运行pm2并在WebStorm上中断

[英]How to run pm2 with node.js ts on debug mode and break on WebStorm

I use latest version of all. 我使用所有的最新版本。

This is my pm2.json 这是我的pm2.json

{
  "name": "testapi",
  "script": "ts-node",
  "args":["/src/index.ts"],
  "watch": [
    "src"
  ],
  "ignore_watch":["node_modules"],
  "env": {
    "PORT": 3333,
    "NODE_ENV": "development",
    "NODE_OPTIONS": "--inspect"
  },
  "inspect": true
}

But I can't debug it from WebStorm with breakpoints. 但是我无法使用断点从WebStorm调试它。 What do I need to do? 我需要做什么?

This is not the answer for your question, but could help you if you need debug. 这不是您问题的答案,但是如果需要调试可以帮助您。

I think pm2 is for deploy environments, so, you could just run your app in debug mode with webstorm, after transpile the code to JS, you could select your index and add a server, then start that server in debug mode. 我认为pm2适用于部署环境,因此,您可以使用webstorm在调试模式下运行您的应用程序,将代码转换为JS之后,可以选择索引并添加服务器,然后以调试模式启动该服务器。

After you have everything working, you could start the server with pm2. 一切正常后,您可以使用pm2启动服务器。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM