简体   繁体   English

如何通过附加到正在运行的进程来使用Visual Studio Code在Node上调试Express js服务器代码

[英]How to debug Express js server code on Node using Visual Studio Code by Attaching to running process

I have: 我有:

  • latest Visual Studio Code 最新的Visual Studio代码
  • Express js 快递js
  • Node js 节点js

This is my Attach configuration: 这是我的附加配置:

{
    "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
        }
    ]
}

This is the gulp task starting the application: 这是启动应用程序的gulp任务:

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);
    });
})

And this is the result of running Attach 这是运行Attach的结果

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

What I'm doing wrong and why? 我在做什么错,为什么? How can I attach Visual Studio Code debugger to running Node app and debug server.js? 如何将Visual Studio Code调试器附加到正在运行的Node app并调试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. 客户端启动语言服务器,因此请确保已启动客户端,以使服务器运行。

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

相关问题 调试Express js应用程序Visual Studio代码: - debug express js application visual studio code: 如何在运行实时服务器的情况下在 Visual Studio Code 中调试 JavaScript - How to Debug JavaScript in Visual Studio Code with live-server Running 如何在不转译代码的情况下在 Visual Studio Code 中使用 ES6 模块调试 Node.JS? - How to debug Node.JS with ES6 modules in Visual Studio Code without transpiling the code? Visual Studio Code 中调试控制台中的 Node.js readline - Node.js readline in debug-console in Visual Studio Code Visual Studio代码无法找到调试节点js的程序 - visual studio code cannot find a program to debug node js 如何在Visual Studio Code中调试单个Nightwatch JS测试 - How to debug a single Nightwatch JS test in Visual Studio Code 如何使用 Visual Studio Code 调试 PHP 页面中的 JS? - How to debug JS in PHP page with Visual Studio Code? 使用Visual Studio Code在Node.JS中定义类型 - Defining types in Node.JS using Visual Studio Code 使用 Visual Studio Code 和 Node.js 调试/学习 javascript - debugging/learning javascript using Visual Studio Code and Node.js Visual Studio 代码断点在使用 TypeScript 的 Node.js 上不起作用 - Visual Studio code breakpoint not working on Node.js using TypeScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM