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

How to debug typescript application with pm2? #3512

Closed
sinelshchikovigor opened this issue Mar 3, 2018 · 6 comments
Closed

How to debug typescript application with pm2? #3512

sinelshchikovigor opened this issue Mar 3, 2018 · 6 comments

Comments

@sinelshchikovigor
Copy link

Is there a way to debug typescript application with pm2?

I'm launching my application using the following command:
"start": "./node_modules/.bin/pm2 start --node-args="--inspect" --watch src/ src/server/server.ts"

I've also tried to specify node-args using json configuration but it doesn't help.

Could you please help me with it?

@michalchochol
Copy link

Hi
if you use ecosystem.json to start your process, you can configure debugger this way:

"apps": [
{
"name": "API",
"script": "app.ts",
"instances": 1,
"exec_mode": "fork",
"watch": [
"app.ts",
"src"
],
"ignore_watch": [
"node_modules"
],
"log_date_format": "YYYY-MM-DD HH:mm:ss Z",
"node_args": [
"--inspect=7000"
]
}
]

IMPORTANT: it works only with ts-node < 5.0.0, because this version does not accept node advanced flags anymore.

I'm looking for the solution to work with newest ts-node version which is installed by default together with typescript using "pm2 install typescript"

@marcj
Copy link

marcj commented Mar 14, 2018

Pm2 with ts-node in current version is currently not usable in development due to handling of node_args. The debugger does not work currently. Downgrading to < ts-node is not easily possible as pm2 installs its own ts-node, always to the latest in

'typescript': {dependencies: [{name: 'typescript'}, {name: 'ts-node@latest'}]},

Any way to fix that?

See TypeStrong/ts-node#537 for more information.

@wallet77
Copy link
Contributor

I'm not sure if it will work because I never tested it.

But you can try overriding typescript installation (to downgrade ts-node) into your ecosystem.json

"dependencies": {
  "typescript": {
    dependencies: [
      {name: 'typescript'},
      {name: 'ts-node@[tagOrVersion]'}
    ]
  }
}

@michalchochol
Copy link

michalchochol commented Mar 14, 2018

Below manual ts-node folder replacement that works for me:

  1. install last version of ts-node working with debugger
    pm2 install ts-node@4.1.0

  2. remove existing ts-node dependency (with version >5.0.0) from pm2:
    rm ~/.nvm/versions/node/v8.9.4/lib/node_modules/pm2/node_modules/ts-node -R

  3. copy existing ts-node@4.1.0 folder to pm2 dependencies:
    cp ~/.nvm/versions/node/v8.9.4/lib/node_modules/ts-node ~/.nvm/versions/node/v8.9.4/lib/node_modules/pm2/node_modules -R

@agborkowski
Copy link

is there any fancy way instead of downgrade ts ?

@RusinovAnton
Copy link

I'm interested in this too

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

6 participants