2

The launch.json's Chrome configuration by default assumes that I am using a Web server. Its content are as follows:

{
    // 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:8080",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

What if I want to debug a client side JavaScript but I am not using a Web server. My pages are simple HTML pages. Can I still use VS Code extension "Debugger for Chrome" to do this? Or something else may be?

Is it possible to use the file:/// protocol inside the url property of the launch.json to enable client side JavaScript debugging in Visual Studio without using a Web server.

I can't find any documentation that addresses this.

1 Answer 1

4

Use the below Json in launch.json

{
    "version": "0.1.0",
    "configurations": [
        {
            "name": "Launch localhost",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost/mypage.html",
            "webRoot": "${workspaceFolder}/wwwroot"
        },
        {
            "name": "Launch index.html",
            "type": "chrome",
            "request": "launch",
            "file": "${workspaceFolder}/index.html"
        },
    ]
}

You can find more explanation in the below mentioned URL VSCODE JS DEBUG

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

2 Comments

Thank you very much. So, I have to change the launch.json for every html file I need to run and debug?

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.