18

I am working on getting the VS Code debugger to attach to Chrome as part of my regular workflow.

I keep Chrome running all the time, and the highly-regarded VS Code Live Server extension opens my project in a new tab, which I like. I would like to be able to attach the VS Code debugger to this instance, but it looks like I have to start Chrome from the command line with

sudo /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222

Several questions:

  1. Is there a way to modify Chrome's configuration file so that it always starts with that flag set?
  2. Is that a stupid thing to do?
  3. Do I really need the sudo in the line above? Some sources do not have it.
  4. Alternatively, is there a way to create a desktop/toolbar shortcut to chrome that will start it will remote debugging enabled?

Thanks!

PS I see the related SO question for Windows.

Nat Kuhn
  • 9,493
  • 5
  • 18
  • 26

1 Answers1

9

There are various Mac answers that used to work that don't anymore. I found one that does and built a double-clickable icon. I posted it on GitHub.

Apparently it's also pretty easy to do using Automator.

syntagma
  • 23,346
  • 16
  • 78
  • 134
Nat Kuhn
  • 9,493
  • 5
  • 18
  • 26
  • 1
    I made it much easier to use the solution I posted on GitHub. There is now a .dmg that you can download; it has a double-clickable Chrome icon with "9222" superimposed, so that you can tell it from the actual Chrome. – Nat Kuhn Dec 09 '19 at 03:45
  • How can anyone knew that clicking in Application Info's Icon and hitting Cmd+V you can replace the icon? Thanks for the tip – julianm Jun 06 '22 at 19:32
  • @NatKuhn "dmg" nice but dangerous – Bruno Oct 09 '22 at 00:40
  • @BGBRUNO Can you explain why it's dangerous? Thanks! – Nat Kuhn Oct 10 '22 at 06:07
  • 4
    @NatKuhn nobody knows what is in compiled version – Bruno Oct 11 '22 at 02:32