我可以使用VSCode在本地运行/debuggingHeroku Node.js应用程序吗?


TL; DR

在Microsoft VSCode v1.6.1上 ,如何:

  1. 正确设置运行时可执行文件?
  2. 正确地传递Heroku参数 ?
  3. 运行Heroku的Node.js应用程序?
  4. debuggingHeroku的Node.js应用程序?

细节

我创build了一个使用CLI命令启动的Heroku Node.js应用程序:

heroku local web 

并在5000端口成功启动。

我正在尝试使用Microsoft Visual Studio Code ,使用以下launch.jsonconfiguration进行debugging:

 { "name": "Launch", "type": "node", "request": "launch", "program": "${workspaceRoot}/app.js", "stopOnEntry": false, "args": [], "cwd": "${workspaceRoot}", "preLaunchTask": null, "runtimeExecutable": "/usr/local/bin/heroku", "runtimeArgs": [ "local web", ], "env": { "NODE_ENV": "development" }, "console": "internalConsole", "sourceMaps": false, "outFiles": [] } 

但VSCode自动将--debug-brkparameter passing给heroku,导致错误:

 /usr/local/bin/heroku --debug-brk=23080 'local web' app.js ! `--debug-brk=23080` is not a heroku command. ! See `heroku help` for a list of available commands. 

VSCode也没有find没有完整path的heroku命令(好像是不加载PATH环境variables)。

关于如何设置编辑器的任何想法?

以下解决scheme适用于我:

1)在你的proc文件中添加参数–debug到节点进程

 web: node --debug server.js 

debugging器默认侦听端口5858

2)运行节点进程后,打开VSCode并将以下configuration添加到launch.json文件中

 { "type": "node", "request": "attach", "name": "Attach to Process", "port": 5858 } 

3)最后,点击VSCode中的播放button,select“附加到进程”,它应该debugging你的过程。