How to prevent to step into node_modules

2020-04-16 02:13发布

问题:

How to prevent to step into node_modules/*.js files when debugging the typescript project files in vs code editor. When I start a debug process with a berakpoint on my typescipt file, I want to step over js files under node_modules directory automatically.

// my launch.json

{
  "version": "0.2.0",
  "configurations": [ {
      "name": "LaunchChrome",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:4200",
      "sourceMaps": true,
      "trace": true,
      "webRoot": "${workspaceRoot}",
      "userDataDir": "${workspaceRoot}/.vscode/chrome",
       "runtimeArgs": [ "--disable-web-security"]
    } ]
}

回答1:

Add the following to your launch.json...

"skipFiles": [
    "${workspaceRoot}/node_modules/**/*.js"
]

From the sound of your question, you may also want to exclude the following...

"skipFiles": [
    "${workspaceRoot}/node_modules/**/*.js",
    "<node_internals>/**/*.js"
]

Which then also excludes node internal files (net.js, events.js, etc) if you wish.

Via documentation here