【问题标题】:Visual Studio Code won't stop at breakpoint in NativeScript appVisual Studio Code 不会在 NativeScript 应用程序的断点处停止
【发布时间】:2017-07-13 11:01:33
【问题描述】:

我想使用 nativescript 创建一个小型 android 应用程序,但是在没有调试器的情况下这样做会使事情变得比必须的要慢得多。 因为它只是一个 JS 应用程序,所以我决定尝试一下 Visual Studio Code,至少在他们的教程视频中,它似乎可以很好地与 NativeScript 应用程序配合使用,但是当我尝试使用它时,它似乎并没有停止任何断点。这是我的 VSC 启动配置:

    {
        "name": "Launch on Android",
        "type": "nativescript",
        "request": "launch",
        "platform": "android",
        "appRoot": "${workspaceRoot}",
        "sourceMaps": true,
        "watch": true,
        "tnsArgs": "--emulator"
    }

我注意到,如果我将 "stopOnEntry": true 添加到此配置中,应用程序实际上会在开始时停止,但看起来 VSC 的调试器并没有真正附加到进程,因为“播放”按钮仍然处于禁用状态。

这是我的 package.json

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "scripts": {
    "recreate": "rm -rf platforms && rm -rf node_modules && npm install && tns platform add android"
  },
  "nativescript": {
    "id": "org.nativescript.forni",
    "tns-android": {
      "version": "2.5.1"
    }
  },
  "dependencies": {
    "lodash": "^4.17.4",
    "nativescript-oauth": "^1.2.1",
    "nativescript-telerik-ui": "^1.5.1",
    "tns-core-modules": "2.4.4"
  },
  "devDependencies": {
    "babel-traverse": "6.21.0",
    "babel-types": "6.21.0",
    "babylon": "6.15.0",
    "lazy": "1.0.11"
  }
}

这是我的 app.js,这是我希望打破的地方:

const application = require("application");
application.start({ moduleName: "views/login/login" });

我使用的是 Windows 10。我也尝试直接在我的三星 Galaxy S7 上运行该应用程序,但它的工作方式完全相同。

【问题讨论】:

  • 我在 Ubuntu 上遇到了同样的问题,一旦它确实在设置的断点处停止,但似乎这是一个错误 :).. 我无法重现它。

标签: javascript android debugging visual-studio-code nativescript


【解决方案1】:

在我的 Win10 机器上,我遇到了类似的问题。 正如它出现的那样,调试器已附加到较晚。 您可以检查添加触发功能的按钮并在该功能内设置断点。按下按钮后它应该可以工作。

要解决此问题,请尝试在 launch.json 文件中的 tnsArgs 中添加 --debug-brk 选项:

 {
      "name": "Launch on Android",
      "type": "nativescript",
      "request": "launch",
      "platform": "android",
      "appRoot": "${workspaceRoot}",
      "sourceMaps": true,
      "watch": true,
      "stopOnEntry": false,
      "tnsArgs": ["--debug-brk"]
    }

文档:https://docs.nativescript.org/tooling/debugging/debugging

【讨论】:

    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 2019-03-19
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    相关资源
    最近更新 更多