DEV Community

Yury Troynov
Yury Troynov

Posted on • Updated on

Debugging TypeScript (Node.js) in IntelliJ IDEA

Some time ago I've started to write typescript on server-side. and right after I've faced a problem with debugging it, after searching how to do it on the internet I found out that some of the tutorials are not working or not full, so I decided to create my own. which is working :) and contains everything you need :) So let's do it.

Dependencies:

  • typescript
  • ts-node
  • tsconfig-paths

let's install them:

npm i -S typescript ts-node tsconfig-paths

create index.ts file touch index.ts

Now we need to add some example code for our debugging, we add it to index.ts file:

function examplefunc(num1:number, num2: number){
const a = num1;
const b = num2;
const c = a + b:
return c;
}

create debug listener config in ide
debug listener config
create config -> attach to Node.js/Chrome

create run config for index.ts
ide run config

NodeParameters: --inspect --require ts-node/register -r tsconfig-paths/register

javascript file: index.ts

start debugger listener config debuggerListener

drop breakpoint in code and run debugts config

result

now execution will stop at the breakpoint, now we can easily debug ts files in IntelliJ :)

Top comments (0)