VSCode 调试时 类 中的未绑定断点 Node.js

VSCode unbound breakpoints in classes while debugging Node.js

我正在做一个 Node.js 项目。

我在调试代码时遇到问题,即当我开始调试时,一些断点变得无界。

它只出现在class定义中。 classes 中没有的另一个断点工作正常。

正如我所想,因为我的 class 方法不是静态的,所以 class 定义中的断点不适用于使用 class.

创建的对象

如果是这样,有没有好的方法来调试 class 方法中的代码?或者,如果以上不是我问题的原因,我应该添加一些配置吗?

谢谢。

下面是我的一些代码(the class file I tried to make breakpointslaunch.json):

  1. class文件我试过打断点

我尝试在 next() 函数中放置断点,但没有成功。 (我从原来的代码中删除了一些不必要的代码)

const uniqueArrayByName = require('../tools/uniqueArrayByName')

class paginator {
  constructor(message, promises, step, length, preProcess){
    if(step < 1) throw new Error('a step must be a integer bigger than 0');
    this.message = message;
    this.step = step;
    this.cursor = -step;
    this.promises = promises;
    this.preProcess = preProcess

    this.numberOfCards = length;
  }

  prev(){
    let targetCards = this.cards.slice(this.cursor - this.step, this.cursor);
    this.cursor = this.cursor - this.step;

    return this.showMessages(targetCards);
  }

  async next(){
    this.cursor = this.cursor + this.step;

    if ( !this.cards || this.cursor + this.step >= this.cards.length ) {
      if( this.promises.size > 0 ){
        let res = await promises[0];
        let cards = res.data.cards;
        
        cards = this.preProcess(cards);
        this.cards = uniqueArrayByName(this.cards.concat(cards));
        this.promises = this.promises.slice(1);
      }
    }
    let targetCards = this.cards.slice(this.cursor, this.cursor + this.step);

    return this.showMessages(targetCards);
  }

  
  get getCardsLength(){
    return this.cards.length;
  }

  get getCursor(){
    return this.cursor;
  }
}

module.exports = paginator;
  1. launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/../helloworld/app.js",
            "runtimeArgs": [
                "--preserve-symlinks"
            ]
        }
    ]
}

我发现了我的问题:我刚刚重新安装了 VSCode,它成功了。好像有些文件坏了。