0

I am trying to use debug mode in my react native application with visual studio code. I am using the command npx react-native run-android. It is activating the react native debugger, but it is not reaching any breakpoint in my application.

I did not find any tutorials to activate debug with npx, so could you guys show me one or explain me what is happening wrongly in this setup?

this is my launch.json

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Debug React Native",
        "program": "${workspaceRoot}/.vscode/launchReactNative.js",
        "type": "reactnative",
        "request": "launch",
        "platform": "android",
        "sourceMaps": true,
        "outDir": "${workspaceRoot}/.vscode/.react"
    },
]

}

An interesting thing it is happening is once it is running the application if I click on the start debugging button my application restarts and it shows a message on debug console:

Launched debug configuration contains 'program' property which is deprecated and will be removed soon. Please replace it with: "cwd": "${workspaceFolder}" Could not debug. The "path" argument must be of type string. Received type undefined

Scallibur
  • 31
  • 4

1 Answers1

2

Since I have not received any answer, I took 3 days to discovered what was happening.

this is the correct configuration:

{
"version": "0.2.0",
"configurations": [
    {
    "name": "Attach to packager",
    //"program": "${workspaceRoot}/.vscode/launchReactNative.js",
    "type": "reactnative",
    "request": "attach",
    "sourceMaps": true,
    "cwd": "${workspaceFolder}",
    //"outDir": "${workspaceRoot}/.vscode/.react"
    },
]

}

  • Must run the command npx react-native run-android
  • Once the android emulator is running batch job must be stopped in the terminal
  • Go to the debug tab in vs code and run the application
  • ctrl + m on android emulator
  • click on debug option

Those were the baby steps that I did in order to have the application run in debug mode.

Scallibur
  • 31
  • 4
  • Thanks!! This worked. I have been struggling with this for an embarrassing amount of time! – Jwags Jul 02 '20 at 20:25