NodeJS debugging not working in IntelliJ 2020.1

IntelliJ IDEA 2020.1 (Ultimate Edition)
Build #IU-201.6668.121, built on April 8, 2020
Runtime version: 11.0.6+8-b765.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.3.0-46-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 16
Non-Bundled Plugins: net.masterthought.dlanguage, io.protostuff.protostuff-jetbrains-plugin, org.antlr.intellij.plugin, org.jetbrains.plugins.go-template, org.jetbrains.plugins.go, org.intellij.scala, org.jetbrains.plugins.vue, com.intellij.lang.jsgraphql
Current Desktop: GNOME

 

Debugging of Node.js just seemed to stopped working in Intellij a while ago.

I have the following (example) configuration, using a project created from scratch using the Node.JS project wizard:

 

When trying to debug the app, IntelliJ starts NodeJS, apparently fails to connect to the debugger and kills the process after a while:

 

The very same project/configuration works fine in WebStorm (2020.1):

 

It seems like Intellij fails to set the NODE_OPTIONS environment variable. Unchecking the 'js.debugger.use.node.options' variable in the WebStorm Registry causes it to switch to command line options, but IntelliJ, again, does nothing and fails the same way.

Thing is I could swear this was working like a week ago, but I do not remember whether I updated IntelliJ in the meantime. Anyways, any pointers on how to fix this? Need to use IntelliJ instead of WebStorm since I work with a whole bunch of languages.

10 comments
Comment actions Permalink

please try uninstalling Go plugin - does the issue persist? Must be https://youtrack.jetbrains.com/issue/WEB-44721

0
Comment actions Permalink

I'm having the exact same problem with 2020.2 (mac 10.15.5, node 12.16.1), uninstalling Go doesn't help

1
Comment actions Permalink

Disabled a bunch of plugins (entire java and android support and a bunch of others) and it started to work. If someone else having this issue I recommend trying to disable all plugins (except js and debugger) and see if this helps, if yes you can binary search the faulty plugin.

1
Comment actions Permalink

I also cannot make the Node debugger work. It correctly connects to the Node process but does not stop on any breakpoint. 

Disabling all unused plugins does not solve the problem, unfortunately :(

0
Comment actions Permalink

Jacek Jaroczynski what Node.js version do you use? Please share a screenshot of your Node.js run configuration

0
Comment actions Permalink

Hi Elena,

I use Node v14.4.0. 

As I mentioned, the connection to the Node works well. I can see the following:

Debugger listening on ws://127.0.0.1:9229/4f8e91eb-e0b4-45be-9edc-87f72245fd2d
5:15:20 PM web.1 | For help, see: https://nodejs.org/en/docs/inspector
5:15:26 PM web.1 | Debugger attached.

However, IDEA does not stop on breakpoints:

Thanks,
Jacek

0
Comment actions Permalink

Works fine for me

What command do you use to start your app? Why aren't you using the Node.js run configuration for debugging? Also, could you share a test project the issue can be repeated with?

0
Comment actions Permalink

There are many other things going around and starting it through yarn is simpler:

nodemon ./server/server.js -V -e 'js,jsx' -i './tests/' -i './app' --exec 'node --inspect --require @babel/register'"

 

0
Comment actions Permalink

I'm not sure what you are trying to debug and how... No .js files are passed to node in --exec. If I use the similar command, like

nodemon src/app.js -V -e 'js,jsx' --exec node --inspect --require @babel/register

the node args are passed to application, not to node itself, and debugging doesn't work:

[nodemon] starting `node src/app.js --inspect --require @babel/register`

but, if I use

nodemon -V -e 'js,jsx' -x node --inspect-brk --require @babel/register src/app.js

it works as expected - once I attach the debugger, breakpoints in the app are hit

0
Comment actions Permalink

Alright. I got it working after your tips. 

Few hints that might help others:

  • --inspect-brk does not work in my case. Starting Node halts and nothing happens. 
  • --inspect works well
  • moving the src/app.js from Nodemon to Node does not change anything. Nodemon still passes this argument correctly to Node so both versions work well
  • the problem lied in the fact that due to use of "nvm" there were two Node processes and I was attaching to the incorrect one (looking deeper into the logs I notice "[nodemon] spawning" info, and then "ps" command told the rest

Elena Pogorelova, thank you so much for looking into this. I shared the details, so maybe it will help others and save you some time in the future :)

Cheers,
Jacek

0

Please sign in to leave a comment.