使用Visual Studio Code进行React Native调试不起作用 [英] React Native debug with Visual Studio Code not working

查看:689
本文介绍了使用Visual Studio Code进行React Native调试不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试将React Native与Visual Studio Code一起使用(应该是最好的),但是当我尝试调试时却给了我一个错误.
我已经安装了React Native Tools扩展,但是当我尝试启动(F5)时,它返回"[错误]无法调试.确定根目录中安装了react-native npm软件包吗?"
我还尝试使用F1> React Native发送命令:运行Android",但返回错误当前工作空间不是React Native项目".

我正在使用Ubuntu 16.04 LTS.
Visual Studio代码1.11.2
react-native-cli:2.0.1
反应本机:0.43.3



i'm trying to use React Native with Visual Studio Code (which should be the best one) but it gives me an error when I try to debug.
I have installed the React Native Tools extension but when I try to start (F5) it returns "[Error] Could not debug. Sure that the reactive-native npm package is installed at the root? "
I also tried sending the command with F1 "> React Native: Run Android" but it returns error "Current workspace is not a React Native project."

I'm using Ubuntu 16.04 LTS.
Visual Studio Code 1.11.2
react-native-cli: 2.0.1
react-native: 0.43.3

你们中的任何人都使用Visual Studio Code吗?你有这些问题吗?

Does any of you use Visual Studio Code? Do you have these problems?

我的launch.json(由扩展React Native Tools生成的唯一文件)

My launch.json (the only file generated from extension React Native Tools)

{
    "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",
            "target": "iPhone 5s",
            "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"
        }
    ]
}

推荐答案

我想这个答案有点迟了.

I guess this answer is a tad late.

您的问题是vscode在您的react-native的PATH引用上找不到.

Your problem is that vscode could not find on your PATH references of react-native.

如果您是使用npm安装的,请尝试以下操作:

If you installed it using npm try the following:

npm install react-native --global

npm install react-native --global

这应该将其安装在您的路径中.重新启动vscode,您应该一切顺利.

This should install it in your path. Restart vscode and you should be good to go.

这篇关于使用Visual Studio Code进行React Native调试不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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