2

I am unable to open the localhost and unable to debug TypeScript file in VS Code because of some error. I have set target to "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--remote-debugging-port=9222" in Chrome Properties. I got the error as [debugger-for-chrome] Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9222. Refer the following image for error after killing all chrome.exe processes. Can someone help me to solve this issue? Thanks in advance.

Failed to Load Error

.vscode/launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch index.html with sourcemaps",
            "type": "chrome",
            "request": "launch",
            "file": "${workspaceRoot}/index.html",
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}"
        },
        {
            "name": "Launch localhost with sourcemaps",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}"
        },
        {
            "name": "Attach with sourcemaps",
            "type": "chrome",
            "request": "attach",
            "port": 9222,
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}"
        }
    ]
}

tsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "sourceMap": true
    }
}

app/app.ts:

var x = 1;
console.log(x); //made debugger here in VS Code

index.html:

<!doctype html>
<html>
<body>
    <h3>TypeScript Debugger</h3>

    <script src="app/app.js"></script>
</body>
</html>
8
  • Try killing all chrome.exe processes in your Task Manager and then try launching again with the remote debugging flag Commented Jun 29, 2016 at 21:37
  • Can you post those text files as, you know, text? If someone wanted to recreate your situation, they'd have to retype all of that code. Commented Jun 29, 2016 at 21:39
  • @Gideon I have tried killing all chrome.exe processes. Now I got "Failed to load resource: net::ERR_CONNECTION_REFUSED (http://localhost:3000/)" error which you can refer in this post which i just edited Commented Jun 29, 2016 at 21:52
  • @MikeMcCaughan I have edited this post. Does it makes sense? Commented Jun 29, 2016 at 21:54
  • 1
    Much better, but please do include the text of the error message. The problem is that images are not searchable, so people trying to find this by searching would be out of luck. Commented Jun 29, 2016 at 21:56

1 Answer 1

2

Not directly answering the question but perhaps still useful: did you know that you can debug typescript directly in Chrome, including breakpoints? You don't even need to install a plugin. See this screenshot:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

this is cool. but how can i debug nativescript js project(for android & ios) in vs code?
can you check my other post regarding nativescript emulator issue and give me a solution?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.