Last active
March 14, 2024 11:31
-
-
Save cecilemuller/2963155d0f249c1544289b78a1cdd695 to your computer and use it in GitHub Desktop.
Run ts-node in VSCode Debugger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Example", | |
"type": "node", | |
"request": "launch", | |
"runtimeExecutable": "node", | |
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"], | |
"args": ["src/script.ts", "--example", "hello"], | |
"cwd": "${workspaceRoot}", | |
"internalConsoleOptions": "openOnSessionStart", | |
"skipFiles": ["<node_internals>/**", "node_modules/**"] | |
} | |
] | |
} |
no type checking and need to use tsconfig-paths to resolve paths
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeArgs": ["-r", "ts-node/register/transpile-only", "-r", "tsconfig-paths/register"],
"program": "${workspaceFolder}/packages/lerna/src/cli.js",
"args": ["version"],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"internalConsoleOptions": "neverOpen",
}
]
}
Error: Cannot find module 'ts-node/register/transpile-only'
fixed this by install ts-node locally
npm link ts-node // or yarn add -D ts-node
@iulo thanks,u save my day.
Works perfectly for me
{ "version": "0.2.0", "configurations": [ { "name": "ts-node", "type": "node", "request": "launch", "args": ["${relativeFile}"], "runtimeArgs": ["-r", "ts-node/register"], "cwd": "${workspaceRoot}", "protocol": "inspector", "internalConsoleOptions": "openOnSessionStart" } ] }
Not all heroes wear capes! 😀
Thanks!
General purpose ts-node run opened file (using ${file}
) whereas process-library
is the base-folder of the ts app:
// 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
// https://gist.github.com/cecilemuller/2963155d0f249c1544289b78a1cdd695
{
"version": "0.2.0",
"configurations": [
{
"name": "ts-node",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
"args": ["${file}"],
"cwd": "${workspaceRoot}/process-library",
"internalConsoleOptions": "openOnSessionStart",
"skipFiles": ["<node_internals>/**", "node_modules/**"]
}
]
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much. I used your config to be able to debug typescript in neovim using dap.