VSCode调试器不能与递归函数一起使用

时间:2020-06-05 18:18:23

标签: ubuntu debugging visual-studio-code

我在Ubuntu 20.04上使用VSCode,无法逐步执行递归函数。

该应用程序是NodeJS,没有浏览器。

通过npm start运行

"start": "nodemon --exec babel-node src/try2.js"

逐步执行此非递归功能会很好。

class Person {
  constructor(name) {
    this._name = name // {1}
  }
  get name() {
    // {2}
    return this._name
  }
  set name(value) {
    // {3}
    this._name = value
  }
}

let lotrChar = new Person('Frodo')
lotrChar.name = 'Gandalf' // {5}
lotrChar._name = 'Sam' // {6}
console.log(lotrChar._name)

但是,使用此功能,在调试时在第一条if和第二条function factorial(n) { if (n < 0) { return undefined; } if (n === 1 || n === 0) { return 1; } return n * factorial(n - 1); } const a = factorial(5) console.log('a', a) 语句上都有一个断点

  • 断点消失
  • 代码在函数声明上中断
  • 按“进入”
  • 代码退出,没有其他步骤
{
  "version": "0.2.0",
  "configurations": [
    {
      "sourceMaps": true,
      "smartStep": true,
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": [
        "<node_internals>/**",
        "node_modules"
      ],
      "program": "${workspaceFolder}/src/try2.js",
      "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
      "runtimeArgs": [
        "--nolazy"
      ]
    }
  ]
}

launch.json

this._router.navigate(['/index']);
document.getElementById("loginmodalhref").click();

我做了一个简短的视频来说明问题。

https://youtu.be/fPWffC0BUqw

0 个答案:

没有答案