[英]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.