Reputation: 707
I am using the Debugger for Chrome VS Code extension. I am working on a React project using yarn start
, which opens at localhost:3000
.
I have an already running instance of Chrome where I am logged in using my Google account. However when I hit "Launch Chrome against localhost", the tab opens in a new instance of Chrome where I am not logged in.
How do I force the tab to open in my already-running instance of Chrome instead?
launch.json
:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
]
}
Upvotes: 22
Views: 6970
Reputation: 19498
The FreeCodeCamp guide cited below has the beginnings of the solution, but is outdated and incomplete.
As of 2023, you need to:
launch.json
should now have a request
param in VSCode's to be "attach" instead of "launch"./Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
See the VSCode docs on this for more detail, and commands for other platforms. And, make sure that the port
param in launch.json
matches the port number in the command you use to re-launch Chrome.
Upvotes: 5
Reputation: 51
The following guide was helpful, basically you want to use "request": "attach"
not "request": "launch"
.
Upvotes: 4