简体   繁体   English

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

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

I want to create a small android application using nativescript, but doing so without a debugger makes things much slower than they have to be. 我想使用nativescript创建一个小型的android应用程序,但是这样做没有调试器会使事情变得比它们要慢得多。 Since it's just a JS app, I decided to give a try to Visual Studio Code, which appears to work quite nicely with NativeScript apps at least in their tutorial videos, but when I try to use it, it doesn't seem to stop at any breakpoints. 由于它只是一个JS应用程序,我决定尝试使用Visual Studio Code,它至少在他们的教程视频中看起来与NativeScript应用相当不错,但是当我尝试使用它时,它似乎并没有停留在任何断点。 Here's my VSC launch configuration: 这是我的VSC启动配置:

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

I noticed that if I add "stopOnEntry": true to this configuration, the app actually stops at the very beginning like it should, but it looks like VSC's debugger doesn't really attach to the process, as the Play button remains disabled. 我注意到如果我添加"stopOnEntry": true对于这个配置是真的,应用程序实际上就像它应该停止一样,但看起来VSC的调试器并没有真正附加到进程,因为Play按钮保持禁用状态。

Here's my package.json 这是我的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"
  }
}

and here's my app.js, which is where I hope to break: 这是我的app.js,这是我希望打破的地方:

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

I'm using windows 10. I also tried running the app directly on my Samsung Galaxy S7, but it worked in exactly the same way. 我正在使用Windows 10.我也尝试直接在我的三星Galaxy S7上运行应用程序,但它的工作方式完全相同。

On my Win10 machine, I had a similar issue. 在我的Win10机器上,我遇到了类似的问题。 As it appeared, the debugger had been attached to late. 看起来,调试器已经附加到最近。 You can check with adding a button that triggers function and set a breakpoint inside that function. 您可以通过添加触发函数的按钮来检查并在该函数内设置断点。 It should work after hitting the button. 它应该在按下按钮后工作。

To resolve this issue, try to add --debug-brk option in tnsArgs inside launch.json file: 要解决此问题,请尝试在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"]
    }

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

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

相关问题 Visual Studio 代码断点在使用 TypeScript 的 Node.js 上不起作用 - Visual Studio code breakpoint not working on Node.js using TypeScript 在 Visual Studio Code 中为 dockerized 节点进程设置了断点但尚未绑定 - Breakpoint set but not yet bound in Visual Studio Code for a dockerized node process 无法在Visual Studio中调试JS:验证断点位置 - Can't debug JS in Visual Studio: validating breakpoint location Visual Studio Code不会让我调试我编写的特定代码 - Visual Studio Code won't let me debug a specific code I wrote 在 android studio 上运行 NativeScript 应用 - Running NativeScript app on android studio Visual Studio Code,调试节点 - 我怎样才能达到这个“未验证的断点”? - Visual Studio Code, Debugging Node - How can I hit this 'Unverified Breakpoint'? Visual Studio 2012不会达到断点JavaScript - Visual Studio 2012 does not hit breakpoint javascript Visual Studio Javascript BreakPoint没有被击中,为什么? - Visual Studio Javascript BreakPoint not getting hit, why? 视觉工作室为什么不识别打字稿类型定义? - Why won't visual studio recognise a typescript type defintion? NativeScript ListView itemTap 不会清空项目 - NativeScript ListView itemTap won't empty items
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM