If you're working with IntelliJ, you can debug the app straight from the IDE by adding the appropriate configuration, as follows:
- Select "Edit Configurations" from the "Run" menu (or from the dropdown in the top right toolbar).
- Click on the + sign to add a new Configuration.
- Select "Attach to Node.js/Chrome".
- Add a descriptive name like "Debugger" in the Name field, leave default values elsewhere.
- Make sure you see the project directory under "Remote URLs" before saving the config.
- With your server running, select your new configuration and click on the Bug icon.
Once the debugger has connected to the server, you can make a request form your browser and IntelliJ will pause execution on any breakpoints you add.
More details on this can be found on JetBrain's documentation.
Refer to: https://www.jetbrains.com/help/idea/run-debug-configuration-node-js-remote-debug.html