Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*Vs Code* launch example not working #688

Closed
RuntimeRascal opened this issue Sep 20, 2018 · 4 comments
Closed

*Vs Code* launch example not working #688

RuntimeRascal opened this issue Sep 20, 2018 · 4 comments

Comments

@RuntimeRascal
Copy link

In the README.md an example of how to use ts-node with Vs Code will execute code but not debug code which is what the launch.json file is for I believe.

Please update the example to use the following configuration which will use ts-node to execute and debug the current typescript file

With this config breakpoints will be hit

{
        "type": "node",
        "request": "launch",
        "name": "Debug Current Typescript File",
        "args": [
            "${relativeFile}"
        ],
        "runtimeArgs": [ "--nolazy", "-r", "ts-node/register" ],
        "cwd": "${workspaceRoot}",
        "protocol": "inspector",
}

No need to specify sourcemaps

using "args": [ "${relativeFile}" ] will pass the path of current file open in editor.
you could specify a file if want with "args": [ "${workspaceFolder}/build.ts" ]

With example Code attachs to transpiled javascript

{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "runtimeArgs": [
        "-r",
        "ts-node/register"
    ],
    "args": [
        "${workspaceFolder}/index.ts"
    ]
}

Thank you.

@macouella
Copy link

Add the $workspaceRoot to your launch config's args:

"args": ["${workspaceRoot}/${relativeFile}"],

@josmithua
Copy link

@igimanaloto ${workspaceRoot} is deprecated in favor of ${workspaceFolder}

@FishOrBear
Copy link

        {
            "name": "ts",
            "type": "node",
            "request": "launch",
            "args": [
                "${file}"
            ],
            "runtimeArgs": [
                "-r",
                "ts-node/register"
            ],
            "cwd": "${workspaceFolder}",
            "protocol": "inspector",
            "internalConsoleOptions": "openOnSessionStart"
        }

@cspotcode
Copy link
Collaborator

I have tested the debug configuration in our docs to confirm that it works with breakpoints.
Here is where I did the testing:
https://github.com/TypeStrong/ts-node-repros/tree/vscode-debugging

I tweaked our documentation here: #1466

Closing as I believe no further action is required. Improvements to our documentation can be submitted as pull requests, and Discussions can be used for more open-ended discussion and tech support around debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants