繁体   English   中英

Visual Studio代码不会在NativeScript应用程序中的断点处停止

[英]Visual Studio Code won't stop at breakpoint in NativeScript app

我想使用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的调试器并没有真正附加到进程,因为Play按钮保持禁用状态。

这是我的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上运行应用程序,但它的工作方式完全相同。

在我的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

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM