44

Running nodemon --inspect index.js or nodemon --debug index.js doesn't work.

Node Version : 8.9.1

Nodemon Version : 1.12.6

I have tried these with no luck :

  • nodemon --inspect-brk index.js

  • nodemon -- --inspect index.js

  • nodemon index.js -- --inspect index.js

  • nodemon index.js -- --debug index.js

  • nodemon -- --debug index.js

  • nodemon --inspect --debug index.js

  • nodemon --debug-brk index.js

But node --inspect index.js or node --inspect-brk index.js works. I wonder how? If any alternatives or some kinda workaround would be great too.

Please comment if you need further description.

Pramesh Bajracharya
  • 2,153
  • 3
  • 28
  • 54

6 Answers6

44

For people coming from search engines, there could be a bug related to nodemon and ts-node.

Error: Unknown or unexpected option: --inspect

This can be a way to use inspect with nodemon:

nodemon --exec 'node --inspect=0.0.0.0:9229 --require ts-node/register src/index.ts'

For more information see here

Sir hennihau
  • 1,495
  • 4
  • 18
  • 31
20

SOLVED,

It seems like nodemon@1.12.6 was not passing in this argument. There is a newer version available 1.12.7 where everything works fine and well.

Answer source: Nodemon Issues - Github

Pramesh Bajracharya
  • 2,153
  • 3
  • 28
  • 54
13
nodemon --inspect app.js

The .js part is absolutely necessary.

Charlie
  • 22,886
  • 11
  • 59
  • 90
2

for anyone who is having error ARG_UNKNOWN_OPTION specially with typescript ts-nod and when using auto attach debugger in vscode

example with other arguments like dotenv

nodemon -r dotenv/config ./src/index.ts -- --inspect

khierl
  • 605
  • 1
  • 6
  • 16
1

FINALLY SOLVED

Just follow the below steps are you're good to go:

  1. Make sure you have updated version of nodemon. Update is using following command: npm i nodemon@2.0.4 -g. Make sure to use -g(to give nodemon permissions to run as an administrator). If you get some warnings, try running the same with sudo command sudo npm i nodemon@2.0.4 -g

  2. Then execute the command as: nodemon --inspect app.js

I hope it helped..!!

0

As per official doc Nodemon NPM

You can also pass the inspect flag to node through the command line as you would normally:

nodemon --inspect ./server.js 80

Nikhil Vats
  • 291
  • 3
  • 7