React Native的新手-在Visual Studio Code中调试吗? [英] Very new to React Native - Debugging in Visual Studio Code?

查看:181
本文介绍了React Native的新手-在Visual Studio Code中调试吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照VSCode中的说明进行操作

I followed the instructions for debugging in VSCode as per

https://github.com/Microsoft/vscode-react-native

我用MBP2015的USB电缆连接了Nexus 6P并启用了开发人员选项和USB调试功能,但是当我在VSC中选择调试Android时,我得到了

I attached my Nexus 6P with USB cable with my MBP2015 and enabled Developer Options and USB Debugging but when I select Debug Android in VSC, I get this

[Error] "Could not debug. Android project not found."

我也附上了这张照片。

如果我想在IOS模拟器上进行调试,我选择在VSC中调试IOS,但随后却得到了提示,并且模拟器未启动

If I want to debug on IOS simulator, I select Debug IOS in VSC but then I get this and simulator is not started

[vscode-react-native] Prewarming bundle cache. This may take a while ...
[vscode-react-native] Building and running application.
[vscode-react-native] Executing command: react-native run-ios --simulator
Scanning 772 folders for symlinks in /Users/me/reactnativework/my-app/node_modules (4ms)
ENOENT: no such file or directory, uv_chdir
[Error] "Could not debug. Error while executing command 'react-native run-ios --simulator': Error while executing command 'react-native run-ios --simulator'"

我在这里看到的关于类似问题的帖子很少,但都没有答案或没有答案像我一样。

I have seen few posts here about similar problem but none are answered or are not same issue like I have.

如何使用断点调试最简单的React Native应用程序,以便我可以跟踪代码在Visual Studio Code中的执行方式?

How do I debug a simplest possible React Native app using break points so I can follow how code executes in Visual Studio Code?

这是我的launch.json

Here is my launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Android",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "launch",
            "platform": "android",
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        },
        {
            "name": "Debug iOS",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "launch",
            "platform": "ios",
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        },
        {
            "name": "Attach to packager",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "attach",
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        },
        {
            "name": "Debug in Exponent",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "launch",
            "platform": "exponent",
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        }
    ]
}


推荐答案

发现使用Chrome浏览器可以调试,跟踪,断点,尝试,运行良好

Found out that using Chrome allows debugging, tracing, breakpoints, tried it, working good

这篇关于React Native的新手-在Visual Studio Code中调试吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆