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

doc for execArgs #1716

Closed
simonppg opened this issue May 5, 2020 · 1 comment
Closed

doc for execArgs #1716

simonppg opened this issue May 5, 2020 · 1 comment

Comments

@simonppg
Copy link

simonppg commented May 5, 2020

Do you have some example about the use of execArgs, I'm trying to use nodemon config file without a --inspect-brk configuration flag in "exec" option, and passing it trough npm script, but I can't figure it out how to do it.

nodemon.json

{
  "watch": ["src"],
  "ext": "js,json,ts",
  "exec": "node -r ts-node/register src/index.ts",
  "env": {
    "NODE_ENV": "development"
  },
  "restartable": "rs",
  "ignore": [".git", "node_modules/**/node_modules"],
  "verbose": true,
  "execMap": {
    "ts": "node --require ts-node/register"
  }
}

package.json

"scripts": {
  "dev": "nodemon",
  "dev:debug": "nodemon --inspect-brk"
}

This is what I see when run the script

$ npm run dev:debug

> [email protected] dev:debug /home/user/test-app
> nodemon --inspect-brk

[nodemon] 2.0.2
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 18867 to restart
[nodemon] ignoring: ./.git/**/* node_modules/**/node_modules
[nodemon] watching dir(s): src/**/*
[nodemon] watching extensions: js,json,ts
[nodemon] starting `node -r ts-node/register src/index.ts --inspect-brk`
[nodemon] spawning
[nodemon] child pid: 18880
[nodemon] watching 403 files

It looks like the config flag is passed, but the debugger doesn't start
[nodemon] starting node -r ts-node/register src/index.ts --inspect-brk

It only work if I write it on nodemon.json file like this:
"exec": "node --inspect-brk -r ts-node/register src/index.ts",

Could somebody give me some clue?

@remy
Copy link
Owner

remy commented May 6, 2020

You can't do this on the command line - put simply: nodemon is running two commands that take arguments: the exec (node in this case) and the user script.

So nodemon errs on the side of the user code and passes it to the script.

When the exec is node (bare) then there's hacks to attempt to pass known args to node, but this isn't the case for your code.

I'd be inclined to do something like this (though you'll need to experiment since I'm not a typescript user):

"nodemon:dev": "nodemon --exec 'node --inspect-brk --require ts-node/register'"

@remy remy closed this as completed May 6, 2020
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

2 participants