Unable to attach node debugger in current version of VS code - node.js

I updated VS code to version 1.59.1 and Node debugging no longer works-- I was on a July 2020 build before today. I use nvm to toggle between versions and my nvm default is Node 12.22.
If I run 'node --inspect-brk...' (which I used to do) in a VS code terminal things just hang with a 'debugger listening..' message. If I run 'node --inspect' the program runs, also with a 'debugger listening..' message but no breakpoints are respected. (What's the difference by the way, between inspect and inspect-brk?)
After installing the latest VS code and opening it a dialog appeared saying Node 10 is in my path and so auto-attaching would no longer work. And yes, Node 10 is part of my nvm options, but I'm using Node 12 now via nvm. (That dialog no longer appears now when I open VS Code, for some reason.)
I have the VS code 'auto attach' setting set to 'only with flag'. I've tried the 'always' option too but no luck. I've closed and reopened VS code numerous times to see if a changed setting will work but it hasn't so far. If anyone knows something I may have missed or knows what's what, I'm happy to hear suggestions.

A couple things you can try when the auto-attach doesn't work:
set auto-attach to disabled, then back on 'with flag'
check with env that the NODE_OPTIONS environment variable looks something like:
NODE_OPTIONS=--require /home/me/.vscode-server/data/User/workspaceStorage/dc520ffe0268148fad350d767ccf9350-1/ms-vscode.js-debug/bootloader.js
If not, then it helps to restart your vscode terminal, your bash, etc, until it does.
--inspect-brk tells NodeJS to wait for a debugger to attach before starting the program.
--inspect enables debugging but doesnt wait for a debugger
With vscode's auto-attach, you should use --inspect. It will attach automatically as soon as the program starts.

Related

Cannot start npm serve on MacOS, IntelliJ ultimate on vuejs project

I am failing to start npm serve at Run/Debug Configuration in IntelliJ.
But doing it separately in Terminal within IntelliJ or on plain console works.
What's going on? How to solve that?
Here's what the Run console shows:
/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run serve --scripts-prepend-node-path=auto
> pwdstorage#0.1.0 serve
> node_modules/.bin/vue-cli-service serve
env: node: No such file or directory
Process finished with exit code 127
As mentioned before running the command
/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run serve --scripts-prepend-node-path=auto
on a terminal will properly work; even in IntelliJ.
At IntelliJ/Preferences.../Languages & Frameworks/Node.js and NPM the Node interpreter is set to /usr/local/bin/node and the Package manager is set to /usr/local/lib/node_modules/npm They both do exist.
What the frag is going on?
I would love to get a deeper understanding of the whole thing and do appreciate any inseide views on this.
The issue is that node is not on your $PATH; on MacOSX the environment variables differ between GUI applications and within the terminal. Terminal environment is only available to applications started from terminal.
To solve this problem, IDEA tries to load terminal environment by executing some scripts on startup, but it seems that it can't retrieve all needed stuff in your case - thus the issue. As a workaround, you can try starting IDEA from terminal.
Some links you may find useful: http://apple.stackexchange.com/questions/106355/setting-the-system-wide-path-environment-variable-in-mavericks, http://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications.. The problem is that the way to define system-wide environment variables on Mac changes from one version to another (even minor system updates may break your environment)
As lena answered, it did help. Thank you for your help!
Starting it from the terminal does the job.
In my case I build a starter script
#! /bin/bash
/Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea &
I am running the ultimate version of IntelliJ. The CE version does have another path to start!
The next two nice things to have would be
to have the opened terminal window automatically closed
link it with a proper icon placed on the desktop.
If anyone can help, go ahead!-)

''node' is not recognized as an internal or external command,' in vscode

I'm working on setting up the Suitecloud Development Framework in the NetSuite instance for my company. I've installed Node v16.13.0, npm 8.1.0, and suitecloud 1.3.1.
Running node -v, npm -v, etc. all works from cmd but will throw a not recognized error when I use the terminal in VSCode.
I can get my VSCode to identify node with
SET PATH=C:\Program Files\Nodejs;%PATH%
but this only fixes it for the session and still doesn't give me access to run anything from suitecloud.
I've checked my Environment Variables as per every other help section I've found for this issue but I have 'C:\Program Files\nodejs' in both my user PATH variable any my system PATH variable.
I've tried running VSCode as Admin on the off chance that would fix it, but that didn't solve anything either.
Thank you for your time, hopefully I'm overlooking something simple due to my inexperience with the terminal.
Leaving VSCode overnight and then rebooting seems to have fixed it. I can't explain why, but if you're encountering the same issue I recommend walking away and coming back to it after a long delay.

Node Inspector Console - Can't Execute Command, Goes to Newline Instead

I am running node inspector and trying to run commands in the console.
However, I cannot run them. Instead of running, hitting enter goes to a new line.
Using any other console in chrome works fine, just not Inspector's.
Have tried restarting node and inspector. Any ideas how to fix this?
It seems like Chrome v54, v56 are having this issue for both mac and windows. The easiest solutions so far is downgrading your chrome to v51, and I think some one is working on a PR to fix this.
You can download V51 from here
http://google-chrome.en.uptodown.com/mac
===========================================================================
Another work around is to use command
node --inspect --debug-brk index.js
After running that, goto chrome, open
chrome://inspect you will see a page like this
Find the target and click the inspect, a debugger will be attached automatically and everything works from there. Just like it used to be in node-inspect, and the console works!
read this for more information
http://www.mattzeunert.com/2016/06/01/node-v8-inspector-inspect.html

node.js debug fails when setting breakpoint in script not yet loaded?

I've been using node's simple command-line debugger for various unit tests for quite a while, with no problem. (Edit: not node-inspector, just plain old cmdline node debug <scriptname>, not even using a browser.) Something went wrong the other day, and now it doesn't work any more: it goes dormant when I try to set a breakpoint in a script that hasn't yet loaded.
It works fine when I set a breakpoint in a script that's already loaded (the script I entered on the command line with node debug <scriptname>) -- I can say sb(74) or sb(<scriptname>, 74) and it works fine, as it always has. But when I set a breakpoint for a script not already loaded yet, the debugger just stops working completely. I try c to continue, or n for next, and nothing happens at all: no stopping at a breakpoint, and in fact, no prompt at all. Like the debugger has gone to sleep completely.
I can't remember how the output used to look on startup, but this seems a little strange:
< Debugger listening on [::]:5858
connecting to 127.0.0.1:5858 ... ok
I never looked at it before, but it seems like it would have something other than :: in between the []. Maybe that's a clue?
I've uninstalled and reinstalled both node and npm multiple times; I even uninstalled and reinstalled homebrew and redid all of it from scratch. No joy.
Homebrew 1.0.6
Node v6.7.0
npm 3.10.7

Nodeclipse debugger ignoring breakpoints

I'm using Nodeclipse 0.10 with nodemon, but when I try to debug my script it doesn't stop at any of my breakpoints. I've already seen this and this answer but it hasn't helped.
Occasionally, it will stop on the first line of nodemon, other times it gives me a timeout error from the V8 VM, and sometimes it doesn't do anything at all.
Here's what I've tried so far:
I tried both the "Node application" and the "Node with monitor", neither one works.
Removed nodemon from the preferences page, but then Eclipse just complains it's missing the nodemon path and won't start my script (even if I select "Node application")
Ran node --debug-brk=5858 from the command line and then tried to attach the Eclipse debugger to it
Tried launching the debug from the toolbar button (my personal default) as well as from context menu after right clicking the script file - that just makes it stop on the module.exports line of the script
Ran eclipse --clean
None of it works. As a side note, I did not install Nodeclipse into a new Eclipse environment when I installed it, because it took me a long time to configure my existing one to where I liked it, and I'd rather be able to keep that.
Anyone dealt with this issue before?
Ok, this was embarassingly stupid...somehow, "Skip all breakpoints" had become activated in the Run menu in Eclipse. It's working now.
Thanks everyone for the help though. :)
There is already version 0.11, that has some improvements. You can try it within Enide Studio 2014. But of course, it does not matter whether it is fresh new or updated Nodeclipse version.
You should have paid attention to Nodeclipse Console messages, especially when there are question. You would what actual node command is executing. And I guess there won't be --debug-brk=5858.
Right-click on the launched file, select Properties or press Alt+Enter,
then if in Run/Debug Setting you see 2 or more Launch configuration, delete all or some. They are created automatically during first launch (with message in Nodeclipse Console)
I am currently Nodeclipse project lead, but I don't continue with nodemon support, as I am not using it. I would appreciate feedback, research and suggestion on how to improve that flow.

Resources