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

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

Related

''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.

Unable to attach node debugger in current version of VS code

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.

GitBash - can't enter a new command after starting npm

The solution to my problem may be simple but since I'm a beginner on command line and npm it's been hard to solve it by myself, hopefuly you know the solution:
I cloned a repository and then started npm in the command line. After I enter the command 'start npm', it shows in console that webpack was succesfuly compiled but after no matter what I input, the command line does not execute anything neither shows an error message. I've tried to input, as I've done before, a new command but it seems to add text and not a command. (see the picture)
Or if it is not a problem and i'm just misunderstanding something, please tell me.
After I enter the command 'start npm'
Judging by the image you provided, this command is starting the Webpack dev-server. This is a web server for testing your application, which will monitor your files and rebuild your app when any changes are detected. Once the server is running in a terminal, any further input on your part will be ignored. You can stop the server using Ctrl + C.
Or if it is not a problem and I'm just misunderstanding something, please tell me.
The server instance will (in its default configuration) be listening for connections from localhost on port 8080, so (depending on how your app is set up), it might now be enough to visit http://localhost:3000 in your browser to see your project running. If that's not the case, check the output in the terminal window for something like: Project is running at http://localhost:3035/
It might also help to have a look in package.json to see what else (if anything) npm start is doing.
Further reading: https://github.com/webpack/webpack-dev-server

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

Getting Node to work on windows 7 enterprise

For the better part of a day now I've been trying to get node.js to work on my computer.
Even though I get no errors during installation, whenever i try to run node or npm from the command line I only get the error "Evented I/O for V8 JavaScript has stopped working" and then nothing happens.
I really have no clue why it isn't working and what I have to do to get it to work! Has anyone else ever had the same problem and were you able to fix it somehow?
It seems the problem was with ansicon which I installed together with cucumber.
I was able to fix the problem by running "ansicon -u" in my x64 folder

Resources