Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run ts-node in VSCode Debugger
{
"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/**"]
}
]
}
@WhatIsHeDoing

This comment has been minimized.

Copy link

@WhatIsHeDoing WhatIsHeDoing commented May 8, 2019

Just what I needed, thank you!

@natarajanmca11

This comment has been minimized.

Copy link

@natarajanmca11 natarajanmca11 commented Oct 17, 2019

how to pass the parameters to the service.ts file

@robwilson1

This comment has been minimized.

Copy link

@robwilson1 robwilson1 commented Oct 28, 2019

https://github.com/TypeStrong/ts-node#visual-studio-code

Note: If you are using the --project <tsconfig.json> command line argument as per the Configuration Options, and want to apply this same behavior when launching in VS Code, add an "env" key into the launch configuration: "env": { "TS_NODE_PROJECT": "<tsconfig.json>" }.

@gasparsigma

This comment has been minimized.

Copy link

@gasparsigma gasparsigma commented Dec 22, 2019

Thanks!

@EngMustafaTaha

This comment has been minimized.

Copy link

@EngMustafaTaha EngMustafaTaha commented Jan 21, 2020

Thanks, you save my day

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Jan 24, 2020

Thanks

@fleshka779

This comment has been minimized.

Copy link

@fleshka779 fleshka779 commented Jan 29, 2020

Thanks!

@alexmachina

This comment has been minimized.

Copy link

@alexmachina alexmachina commented Jan 30, 2020

I LOVE YOU

@moohkooh

This comment has been minimized.

Copy link

@moohkooh moohkooh commented Jan 31, 2020

Thanks!

@faridfedora

This comment has been minimized.

Copy link

@faridfedora faridfedora commented Jan 31, 2020

Thanks very helpfull

@vlad-palii

This comment has been minimized.

Copy link

@vlad-palii vlad-palii commented Feb 1, 2020

Hell yeah! Thank you, buddy!

@gugadev

This comment has been minimized.

Copy link

@gugadev gugadev commented Feb 2, 2020

Coat without hero!

@itays

This comment has been minimized.

Copy link

@itays itays commented Feb 5, 2020

awesome! thanks

@rufreakde

This comment has been minimized.

Copy link

@rufreakde rufreakde commented Feb 5, 2020

how to pass the parameters to the service.ts file

"env": {
"TS_NODE_IGNORE": "false",
"LOAD_MAP": "true",
"SAVE_MAP": "false"
}

env: {} property is put into your process.env
example: process.env.SAVE_MAP

@murilojava

This comment has been minimized.

Copy link

@murilojava murilojava commented Feb 12, 2020

Thank's =D

@svrakata

This comment has been minimized.

Copy link

@svrakata svrakata commented Feb 13, 2020

thanks :)

@js2me

This comment has been minimized.

Copy link

@js2me js2me commented Feb 16, 2020

Big thanks!!

@vegerot

This comment has been minimized.

Copy link

@vegerot vegerot commented Feb 20, 2020

Thank you

@Tsourdox

This comment has been minimized.

Copy link

@Tsourdox Tsourdox commented Feb 22, 2020

Fantastic! thx ^^

@pengliheng

This comment has been minimized.

Copy link

@pengliheng pengliheng commented Mar 2, 2020

where is the map...
I cannot find the call stack in the code map

@benwinding

This comment has been minimized.

Copy link

@benwinding benwinding commented Apr 6, 2020

Source-map's don't seem to work with this... 😟

@agniswarm

This comment has been minimized.

Copy link

@agniswarm agniswarm commented Apr 29, 2020

Thanks matey! 👍🏼

@DarkLite1

This comment has been minimized.

Copy link

@DarkLite1 DarkLite1 commented Jun 7, 2020

Awesome! 👍

@yonatann

This comment has been minimized.

Copy link

@yonatann yonatann commented Jun 10, 2020

awesome!!

@itunbridgedev

This comment has been minimized.

Copy link

@itunbridgedev itunbridgedev commented Jul 14, 2020

Not sure why, but with the above config I got this error:

Error: Cannot find module 'ts-node/register/transpile-only'

I changed it to this and it worked:

 "configurations": [
    {
      "name": "Launch TypeScript",
      "type": "node",
      "request": "launch",
      "runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
      "args": ["./server.ts", "--transpile-only"],
      "cwd": "${workspaceFolder}",
      "internalConsoleOptions": "openOnSessionStart",
      "skipFiles": ["<node_internals>/**", "node_modules/**"],
      "env": {
        "TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json"
      }
    }
  ]
@mfeeney

This comment has been minimized.

Copy link

@mfeeney mfeeney commented Jul 27, 2020

👍

@yami-glick

This comment has been minimized.

Copy link

@yami-glick yami-glick commented Aug 8, 2020

Thanks!

@mrjbj

This comment has been minimized.

Copy link

@mrjbj mrjbj commented Sep 9, 2020

I'm getting "unknown file extension" for file "main.ts"

@fake-car

This comment has been minimized.

Copy link

@fake-car fake-car commented Dec 4, 2020

nice

@int8array

This comment has been minimized.

Copy link

@int8array int8array commented Dec 13, 2020

do not use "TS_NODE_TRANSPILE_ONLY": "true" , it will ignore some type check

@serhiiminin

This comment has been minimized.

Copy link

@serhiiminin serhiiminin commented Feb 5, 2021

Hi everyone!
How to deal with typescript paths? It does not recognize imports that are described in tsconfig.json
Tried to use NPM package to register paths, but it does not work.

"args": ["${workspaceFolder}/cli/index.ts", "-r", "tsconfig-paths/register"],
@santiguat

This comment has been minimized.

Copy link

@santiguat santiguat commented Feb 23, 2021

Nothing worked but your settings. Amazing.

@ILyaCyclone

This comment has been minimized.

Copy link

@ILyaCyclone ILyaCyclone commented Feb 24, 2021

Hi people. Any ideas why VS Code debugger is not stopping at break points, while I use configurations from this gist?

@semkeijsper

This comment has been minimized.

Copy link

@semkeijsper semkeijsper commented Apr 12, 2021

Any pointers on how to use this with nodemon?

@iulo

This comment has been minimized.

Copy link

@iulo iulo commented Apr 27, 2021

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
@suricat89

This comment has been minimized.

Copy link

@suricat89 suricat89 commented Jun 10, 2021

Exactly what I was needing, thanks man!

@mikejamesli

This comment has been minimized.

Copy link

@mikejamesli mikejamesli commented Jun 21, 2021

Thanks works like a charm!

@damienleroux

This comment has been minimized.

Copy link

@damienleroux damienleroux commented Aug 24, 2021

The config worked for me! Thx

But I had to use "type": "pwa-node", instead of "type": "node",. Otherwise, I got an error about a missing source map typescript.js.map

@replete

This comment has been minimized.

Copy link

@replete replete commented Nov 5, 2021

Any ideas how to get this working with ts-node-dev??

launch.json

{
	// 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": [
		{
			"name": "Debug ts-node-dev",
			"type": "pwa-node",
			"request": "launch",
			"runtimeExecutable": "node",
			"runtimeArgs": ["--nolazy", "-r", "ts-node-dev/register/transpile-only"],

			"args": ["src/app.ts"],

			"cwd": "${workspaceRoot}",
			"internalConsoleOptions": "openOnSessionStart",
			"skipFiles": ["<node_internals>/**", "node_modules/**"]
		}
	]
}

Error

Process exited with code 1
/usr/local/bin/node --nolazy -r ts-node-dev/register/transpile-only src/app.ts
Uncaught Error: Cannot find module 'ts-node-dev/register/transpile-only'
@chiquetaMariano

This comment has been minimized.

Copy link

@chiquetaMariano chiquetaMariano commented Nov 27, 2021

It works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment