How to setup debugging in VSCode

Hi,
I tried to explore some options for debugging with redwood in VSCode but without success. Someone could give me a hint?

Thank you very much in advance,

Bests,

Hi @pnhoang! Thanks for checking in here. This isn’t quite what you’re looking for, but here’s a brand new VS Code extension for Redwood that does offer some debugging features:
https://marketplace.visualstudio.com/items?itemName=decoupled.studio

1 Like

Hi @thedavid,
Thanks for your response. I’ll check it out.
Is there an option like redwood dev --inspect supported?

Bests,

HI @pnhoang - I’ve had moderate success using the node.js debug terminal in vscode to run yarn rw dev.

image

You could also try setting up a launch.json file, I know the community would appreciate your contribution!

Not at this time, unfortunately. The closest we have is a CLI command for overall project structure inspection. This will tell you if you’re missing files, have incorrect Redwood syntax/conventions, etc.

yarn rw diagnostics

Other than that, as @danny mentioned most people rely on built in VS Code debug.

React/GraphQL/JS debugging is painful, isn’t it? We’re hoping to increasingly make it less painful but recognize we aren’t there yet.

yarn rw dev runs two processes:

  1. webpack-dev-server
  2. redwood’s API dev-server

You can run inspect by doing the following in your project’s directory

cd api
yarn dev-server --inspect

I think we could definitely add this as an option that gets forwarded to the api-dev-server, I’ve added an issue over here: https://github.com/redwoodjs/redwood/issues/936

You could also try setting up a launch.json

Here’s what worked for me:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "pwa-node",
      "request": "launch",
      "name": "Launch API",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "cwd": "${workspaceFolder}/api",
      "envFile": "${workspaceFolder}/.env.defaults",
      "program": "${workspaceFolder}/node_modules/.bin/dev-server"
    }
  ]
}
2 Likes

I just created a pull-request adding a launch.json file

1 Like