-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
in newest version 5.0.0 debugging is not possible using --inspect parameter #537
Comments
node --inspect -r ts-node/register path/to/ts |
That’s the intent. Please check the README or change log or more info and use the node command above for inspecting and other node.js flags. |
Unfortunately this solution does not work with pm2, which uses ts-node by default to run typescript and passes arguments to ts-node via node_args property. |
Can you provide a reference or code snippet so I can verify that claim? Seems like a simple thing to fix. |
Hi, lets assume we have ts-node installed locally via npm and very simple app-test to run:
Normally to run and debug app using node:
To run and debug using pm2 (without typescript installed internally in pm2):
Last two examples do not work, because by default pm2 uses ts-node interpreter to run typescript -> https://github.com/Unitech/pm2/blob/master/lib/API/interpreter.json If we install typescript in pm2 by: pm2 install typescript it also installs the latest version of ts-node. So now we can normally start our script like this:
Last example works without debugger because --node-args are passed to ts-node interpreter and finally ignored. It was working ok with ts-node@4.1.0:
TEMPORARY WORKAROUND: |
Seems like you should submit a fix to |
Could it be as simple as deleting those interpreters? I noticed that the register method is used somewhere else in the code but I’m not familiar with how it works. |
I don't think so it is so simple, but I'm going to try :) Thanks for your time and great project - ts-node really helps and saves a lot of development time. |
Any solution yet to start newest ts-node with inspect via pm2? |
I can't see in the documentation how to combine both a
-- Update: I was fortunate, and able to use |
@majelbstoat Unfortunately it's not possible to combine both, that's a limitation with using node.js |
For everyone looking into this in the future: Node supports passing almost any command line options using an environment variable called |
@Nilos Both ways are possible. You can do |
@blakeembrey I did not know about the I actually think |
nodemon --config config.json { "exec": "node --inspect -r ts-node/register ./src/index.ts" } works well full config {
"verbose": true,
"debug": false,
"exec": "node --inspect -r ts-node/register ./src/index.ts",
"ignore": [
"mochawesome-report",
"node_modules",
"./test",
"**/*.d.ts",
"*.test.ts",
"*.spec.ts",
"fixtures/*",
"test/**/*",
"docs/*"
],
"events": {
"restart": "echo \"[Warning] Remember run npm run test b4 push to dev branch !\""
},
"watch": ["./src"],
"ext": "ts, gql",
"inspect": true
}
``` |
Thanks @agborkowski , your solution works indeed! 👍 |
@agborkowski Thank you very much brother. God bless |
As an alternative to environment variables or
e.g.
|
@agborkowski Not all heroes wear capes. +1 |
If you want to keep using pm2, the Here is my configuration (after running apps:
- name: my-app
script: ./src/index.ts
watch:
- src
env:
NODE_OPTIONS: --inspect |
Why is that? |
@hejiaji You are probably emitting ES6 modules instead of CommonJS? I don't think it has anything to do with |
Oh right! thanks @blakeembrey , then to more specific on my question: |
Figured it out!! using Environment variable to tackle this!
Thanks @blakeembrey |
How can I also provide the Edit Found some help here: Overriding nodemon.json
ts-hook.js
|
@adrian-moisa |
@yleflour perfect solution :) thanks a lot
|
in this approach I am using command like this for typescript nodemon --watch 'src/**/*.ts' --exec node --inspect -r ts-node/register src/index.ts now I want to pass arguments to ts-node how can I do that can you please help me with that I want to pass --files arguments to this but in my case I don't think so it is working I am trying like this nodemon --watch 'src/**/*.ts' --exec node --inspect -r ts-node/register --files src/index.ts |
@bhumit070 If you look at the ts-node documentation for the --files option you can see that there are two ways to enable a setting, either via a flag or via an environment variable.
I would suggest you pass your argument by...
|
In ts-node@5.0.0 --inspect parameter does not work anymore. It was working in previous ts-node version.
The text was updated successfully, but these errors were encountered: