Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native debug with Visual Studio Code not working



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

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

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"
        }
    ]
}
like image 696
Riccardo Avatar asked Feb 11 '26 11:02

Riccardo


1 Answers

I guess this answer is a tad late.

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

If you installed it using npm try the following:

npm install react-native --global

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

like image 178
rodrigoelp Avatar answered Feb 13 '26 09:02

rodrigoelp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!