Standalone debug adapter protocol for react native. Hopefully won't have any specific editor/ide stuff
git clone [email protected]:sultanahamer/nvim-dap-reactnative.git
- Set up the debugger with the following configuration, your configuration may be different but the values must match.
-- using modules
M.config = {
adapters = {
type = "executable",
command = "node",
args = { dbg_path .. "vscode-node-debug2/out/src/nodeDebug.js" },
},
configurations = {
{
type = "node2",
request = "attach",
program = "${file}",
cwd = fn.getcwd(),
sourceMaps = true,
protocol = "inspector",
console = "integratedTerminal",
port = 35000
},
},
}
-- OR
-- directly - typescript react example
dap.adapters.node2 = {
type = "executable",
command = "node",
args = { os.getenv("HOME") .. "/vscode-node-debug2/out/src/nodeDebug.js" },
}
dap.configurations.typescriptreact = {
{
name = "React native",
type = "node2",
request = "attach",
program = "${file}",
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = "inspector",
console = "integratedTerminal",
port = 35000,
},
}
- Run
tsc
from the debuggers directory inside this project's directory. - Start react native metro bundler and make sure its running on 8081
- Run
RN_DEBBUGER_WD=<project_directory> node src/standalone.js
- Now run the app in emulator, once it is running put the app into debug mode. Once in debug mode you should see the output in the image below in the terminal running the debugger
- It would wait on a white screen for debugger to attach, if its not a white empty screen then something didn't go well
- Now in neovim, setup your breakpoints and run dap continue
:lua require('dap').continue()
. - It should start with a debug waiting on some unknown location, ignore it and do continue
:lua require('dap').continue()
, it will again stop on another unknown location, do continue. Now it should start hitting the app's breakpoints - When you finish debugging, if you make code changes, don't just refresh app, close the current debug session with
:lua require('dap').close()
Open emulator and hit rr, it will refresh and wait on white screen Do dap_continue or runlast and you are good to go
๐ค sultanahamer
- Github: @sultanahamer
Give a โญ๏ธ if this project helped you!