mars / heroku-cra-node

⚛️ How to use create-react-app with a custom Node server on Heroku
MIT License
927 stars 226 forks source link

How to debug with vscode? #37

Closed matoelorriaga closed 5 years ago

matoelorriaga commented 5 years ago

I cannot make it work for the server part..

mars commented 5 years ago

I do not use VSCode so don't have any quick solutions.

What kind of errors are you seeing @matoelorriaga ?

Since the Node server and the React front-end are quite literally different apps in the same repo, perhaps you need to open it as two different projects, one is the server in the root of the project, and the other in the react-ui/ subdirectory.

matoelorriaga commented 5 years ago

I managed to get it working.

For react app, add this inside .vscode/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

For the server, add a new npm script, like:

"scripts": {
  "debug": "node --inspect server"
}

and then "attach to node process" using vscode.

mars commented 5 years ago

Thank you for the follow-up @matoelorriaga ☺️ Other VSCode folks will appreciate this!