React Native Debugging with Visual Studio Code not working



I'm trying to use React Native with Visual Studio Code (which should be the best), but it gives me an error when I try to debug.
I installed the React Native Tools extension, but when I try to run (F5) it returns "[Error] Failed to debug. Are you sure the npm-side installed package is root installed?" I also tried to send a command with F1 "> React Native: Start Android", but it returns the error "The current workspace is not a React Native project".

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

Are any of you using Visual Studio Code? Do you have these problems?

My launch.json (single file generated with React Native Tools extension)

{
    "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"
        }
    ]
}

      

+3


source to share


1 answer


I think this answer is a little late.

Your problem is that vscode couldn't find it on your PATH references for react-native.

If you installed it using npm try this:



npm install react-native --global

This should be installed in your path. Reload vscode and you should be good to go.

0


source







All Articles