You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
debugger (ie. node inspect). watch(<variabe>) says it's not defined, but it is. Am I not using this correctly? #2946
One of the options is:
• watch(expr): Add expression to watch list
Ok, I'm stepping through my code. I'm in the middle of a function called by a constructor function, instantiating/creating an object in a class. There's a bunch of let <variable> = <value> statements. If I go into repl and ask it to tell me the values of those variables (eg. I have one variable di for argument's sake) it reports them correctly. But (outside of repl again) I do watch(di) and it says Uncaught ReferenceError: di is not defined.
I can't imaging this is a bug, or it would have been found and fixed by others long before I came along. Am I using this incorrectly? How do I add a variable or expression to the watch list without getting that not defined error?
@DavidTsGit i dunno if you still use it or even care but when using watch() you need to pass it a string to be able to use it properly like: watch("di") instead of watch(di).
Also you can use console.log() inside it for more information like watch("console.log(di)")
P.S: i think in the help text for node inspect it should show watch("expr") instead of watch(expr) because of this very issue, same with expr(expr), p(expr) and unwatch(expr)
Activity
gireeshpunathil commentedon Nov 6, 2020
@Detnator-Neo - can you provide the program that reproduces this?
gireeshpunathil commentedon Dec 9, 2020
inactive, closing. feel free to re-open if it is outstanding
unixatch commentedon Jan 10, 2026
@DavidTsGit i dunno if you still use it or even care but when using watch() you need to pass it a string to be able to use it properly like:
watch("di")instead ofwatch(di).Also you can use
console.log()inside it for more information likewatch("console.log(di)")Source from where i understood it:
https://github.com/nodejs/node/blob/a327288cc6747cf5e07656a1c45fe2f19e0926ae/lib/internal/debugger/inspect_repl.js#L1085-L1088
P.S: i think in the help text for node inspect it should show
watch("expr")instead ofwatch(expr)because of this very issue, same withexpr(expr),p(expr)andunwatch(expr)