Visual Studio debug error "Error processing launch: Error: Could not attach to main target

Viewed 10079

I'm working on a simple project on Codecademy and wanted to make sure I was on the right track. When I tried to debug the code, however, a simple Google page popped up and then an error reading

The error:

I'm very new to coding, so I have no idea where to start.

5 Answers

First, you could try changing the configuration from legacy to a new one

"type": "chrome" -->   "type": "pwa-chrome"

Second increase timeout to 20 s or whatever you like

to looks like that

"configurations": [
    {
      "name": "Launch Chrome",
      "request": "launch",
      "type": "pwa-chrome",
      "timeout": 20000,
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}"
    }

I am using the Debugger for Chrome extension and the same error occurs in version 4.12.9. In the description of the extension says:

Debugger for Chrome

Extension note description

  1. Open the settings of Visual Studio Code (Ctrl + ,) select the Workspace tab
  2. In the section Extensions -> JavaScript Debugger set option Debug > JavaScript: Use Preview to false.

How to change settings

I was also helped by installing the previous version of the Debugger for Chrome extension version 4.12.8

I got the same error, after starting VS Code after a two-month absence. I've reverted to the previous version of "Debugger for Chrome" and it seems okay now.

This can be resolved by VSCode > Setting > Workspace > Extension > Javascript debugger > Debug - Use Preview = Disable.

This will revert to old behavior.

Ok, here I am with visual studio code version 1.57.1.

Visual Studio Code Version 1.57.1

I get the following error.

Error Processing attach error on Visual Studio Code

Press Ctrl + Shift + P to Open settings

Ctrl + Shift + P to Open settings in Visual Studio Code

Select Open Settings JSON under Preferences.

Add the following setting

"debug.javascript.usePreview": false

Settings File in Visual Studio Code

Save the file, restart vs code and try now.

Related