如何通过附加到正在运行的进程来使用Visual Studio Code在Node上调试Express js服务器代码 [英] How to debug Express js server code on Node using Visual Studio Code by Attaching to running process

查看:182
本文介绍了如何通过附加到正在运行的进程来使用Visual Studio Code在Node上调试Express js服务器代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

  • 最新的Visual Studio代码
  • 快递js
  • 节点js

这是我的附加配置:

{
    "version": "0.1.0",
    // List of configurations. Add new configurations or edit existing ones.
    "configurations": [
        {
            "name": "Attach",
            "request": "attach",
            "type": "node",
            // // TCP/IP address. Default is "localhost".
            // //"address": "localhost",
            // // // Port to attach to.
            "port": 5858
        }
    ]
}

这是启动应用程序的gulp任务:

This is the gulp task starting the application:

gulp.task('server', function (cb) {
    exec('mongod', function (err, stdout, stderr) {
      console.log(stdout);
      console.log(stderr);
      cb(err);
    });
    exec('node server.js', function (err, stdout, stderr) {
      console.log(stdout);
      console.log(stderr);
      cb(err);
    });
})

这是运行Attach

And this is the result of running Attach

request 'attach': cannot connect to runtime process (timeout after 10000ms)

我做错了什么,为什么?如何将Visual Studio Code调试器附加到正在运行的Node应用程序并调试server.js?

What I'm doing wrong and why? How can I attach Visual Studio Code debugger to running Node app and debug server.js?

推荐答案

如果在尝试连接调试器时服务器未运行,则会看到此超时错误.客户端启动语言服务器,因此请确保已启动客户端,以使服务器运行.

You will see this timeout error if the server isn't running when you try to attach the debugger. The client starts the language server so make sure you have started the client in order to have a running server.

这篇关于如何通过附加到正在运行的进程来使用Visual Studio Code在Node上调试Express js服务器代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆