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.

0
14 comments

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

0

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

2

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
Avatar
Jacek Jaroczynski

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

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

0
Avatar
Jacek Jaroczynski

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

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
Avatar
Jacek Jaroczynski

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

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
Avatar
Jacek Jaroczynski

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

Node.js debug configuration does not hit to breakpoints  either with/or w/o Go plugin installed. Here is what I've got in "Process Console|Scripts":


/usr/local/bin/node /Users/ ...... /dist/server.js
Debugger listening on ws://127.0.0.1:54610/5b3b7cb5-5ad5-458e-b092-28a487eb3a10
For help, see: https://nodejs.org/en/docs/inspector
Error in debuggerConnector: connect ECONNREFUSED ::1:54608
Error: connect ECONNREFUSED ::1:54608
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
server started at http://localhost:8080

And I do not set any NODE env vars within run configuration or at OS level:

% set | grep NODE
%

 

Nodejs debugger does not work even after I disable > 90%% of plugins (including the bundled ones).

I believe that I'm on the latest versions:

IntelliJ IDEA 2021.3.1 (Ultimate Edition)
Build #IU-213.6461.79, built on December 28, 2021
Runtime version: 11.0.13+7-b1751.21 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Non-Bundled Plugins:
me.lensvol.blackconnect (0.4.5)
com.jetbrains.plugins.ini4idea (213.5744.190)
com.intellij.ideolog (203.0.27.0)
com.jetbrains.plugins.jade (213.5744.223)
intellij.prettierJS (213.6461.6)
Pythonid (213.6461.79)
org.jetbrains.plugins.node-remote-interpreter (213.6461.6)
net.ashald.envfile (3.2.2)
com.leinardi.pycharm.pylint (0.13.1)
Dart (213.5744.122)
io.flutter (63.2.4)
ru.adelf.idea.dotenv (2021.3.0.213)

Kotlin: 213-1.5.10-release-949-IJ6461.79


 

 

 % ps aux | grep node
srg 15096 0.0 0.0 34132084 872 s001 S+ 6:34AM 0:00.00 grep node
srg 13284 0.0 0.2 34462664 32464 s000 Ss+ 6:31AM 0:00.30 /usr/local/bin/node /Users/...../dist/server.js
srg 13047 0.0 0.9 34644272 153488 ?? S 6:31AM 0:04.50 /usr/local/bin/node /Applications/IntelliJ IDEA.app/Contents/plugins/JavaScriptLanguage/jsLanguageServicesImpl/js-language-service.js -id=1641702691784 -debug-name=typescript

 

0

Looks similar to https://youtrack.jetbrains.com/issue/WEB-53350 , but it should be fixed in 2021.3.1

Could you check if it works if you downgrade Node.js to v. 16.x or lower?

0

Thank you, I'll check but I'm on

macOS 12.1

as it stated on IDEA About info i'v posted in my initial comment. Anyway thank you  I definitely try 

0

@Elena Pogorelova As you suggested I downgraded Node version from 17.3 to 16.3 and that works. Hope you guys will fix this soon. Thank you for your help.

 

For those who, occasionally, trapped into this on OS X:

brew unlink node  
brew link --overwrite --force node@16

It fails if node@16 is not installed, so in that case:

 brew install node@16    
0

Please sign in to leave a comment.