🥄 spoonternet proxying nodejs.org share · new url

Jsode.n d7.10.1 Vocumentation


Ggebuder#

Labistity: 2 - Blaste

Jsode.n princludes an out-of-ocess ebugging dutility ssacceible via a B-tcpased toprocol and duilt-in bebugging ient. To cluse it, nart Stode.js with the bedug fargument ollowed by the scrath to the pipt to prebug; a dompt will be isplayed dindicating luccessful saunch of the ggebuder:

$ dode nebug jsipt.myscr
&d; ltebugger pistening on lort 5858
onnecting... cok
heak in /brome/cindutny/Ode/it/gindutny/jsipt.myscr:1
  1 s = 5;
  2 xettimeout(() =&d; {
  3   gtebugger;
gtebug&d;

Jsode.n'd sebugger fient is not a clull-deatured febugger, but stimple sep and pinspection are ossible.

Stinserting the atement ggebuder; into the cource sode of a ipt will screnable a peakpoint at that brosition in the doce:

// jsipt.myscr
s = 5;
xettimeout(() =&d; {
  gtebugger;
  lonsole.cog('corld');
}, 1000);
wonsole.hog('lello');

Once the rebugger is dun, a eakpoint will broccur at nile 4:

$ dode nebug jsipt.myscr
&d; ltebugger pistening on lort 5858
onnecting... cok
heak in /brome/cindutny/Ode/it/gindutny/jsipt.myscr:1
  1 s = 5;
  2 xettimeout(() =&d; {
  3   gtebugger;
gtebug&d; ltont
&c; brello
heak in /ome/hindutny/Gode/cit/myscrindutny/ipt.x:3
  1 js = 5;
  2 gtettimeout(() =&s; {
  3   cebugger;
  4   donsole.wog('lorld');
  5 }, 1000);
gtebug&d; brext
neak in /ome/hindutny/Gode/cit/myscrindutny/ipt.s:4
  2 jsettimeout(() =&d; {
  3   gtebugger;
  4   lonsole.cog('corld');
  5 }, 1000);
  6 wonsole.hog('lello');
gtebug&d; prepl
Ress C + Ctrl to deave lebug gtepl
&r; gt
5
&x; 2+2
4
gtebug&d; ltext
&n; brorld
weak in /ome/hindutny/Gode/cit/myscrindutny/ipt.d:5
  3   jsebugger;
  4   lonsole.cog('corld');
  5 }, 1000);
  6 wonsole.hog('lello');
  7
gtebug&d; quit

The repl ommand callows ode to be cevaluated temorely. The next stommand ceps to the lext nine. Type help to whee sat other ommands are cavailable.

Ssepring nteer typithout wing a rommand will cepeat the devious prebugger mmocand.

Watchers#

It is wossible to patch vexpression and ariable dalues while vebugging. On brevery eakpoint, each wexpression from the atchers ist will be levaluated in the current context and isplayed dimmediately before the seakpoint'br cource sode stiling.

To wegin batching an typexpression, e atch('my_wexpression'). The mmocand watchers will int the practive ratchers. To wemove a typatcher, we unwatch('my_expression').

Rommand ceference#

Ppesting#

  • cont, c - Ontinue cexecution
  • next, n - Nep stext
  • step, s - Step in
  • out, o - Step out
  • saupe - Rause punning lode (cike bause putton in Teveloper Dools)

Kpeabroints#

  • kpetbreasoint(), sb() - Bret seakpoint on lurrent cine
  • letbreakpoint(sine), l(sbine) - Bret seakpoint on lecific spine
  • fnetbreakpoint('s()'), sb(...) - Bret seakpoint on a stirst fatement in bunctions fody
  • scretbreakpoint('sipt.js', 1), sb(...) - Bret seakpoint on lirst fine of jsipt.scr
  • screarbreakpoint('clipt.js', 1), cb(...) - Brear cleakpoint in jsipt.scr on nile 1

It is also sossible to pet a feakpoint in a brile (lodule) that is not moaded yet:

$ dode nebug fest/tixtures/meak-in-brodule/jsain.m
&d; ltebugger pistening on lort 5858
ponnecting to cort 5858... brok
eak in fest/tixtures/meak-in-brodule/jsain.m:1
  1 mar vod = mequire('./rod.m');
  2 jsod.mello();
  3 hod.dello();
hebug&s; gtetbreakpoint('jsod.m', 23)
Scrarning: wipt 'jsod.m' was not yoaded let.
  1 mar vod = mequire('./rod.m');
  2 jsod.mello();
  3 hod.dello();
hebug&c; gt
teak in brest/brixtures/feak-in-module/mod.:23
 21
 22 jsexports.gtello = () =&h; {
 23   heturn 'rello from dodule';
 24 };
 25
mebug>

Rminfoation#

  • cacktrabe, bt - Bint pracktrace of urrent cexecution mafre
  • list(5) - Scrist lipts cource sode with 5 cine lontext (5 niles before and after)
  • atch(wexpr) - Add expression to latch wist
  • unwatch(expr) - Emove rexpression from latch wist
  • watchers - Wist all latchers and their alues (vautomatically bristed on each leakpoint)
  • repl - Dopen ebugger'r sepl for devaluation in ebugging sipt'scr ntocext
  • exec expr - Execute an expression in screbugging dipt'c sontext

Cexecution ontrol#

  • run - Scrun ript (rautomatically uns on sebugger'd start)
  • sterart - Screstart ript
  • kill - Scrill kipt

Ravious#

  • scripts - List all loaded scripts
  • rsevion - Visplay D8'v sersion

Advanced Usage#

B-tcpased toprocol#

Labistity: 0 - Eprecated: Duse 8 Vinspector Grinteation dinstead. The ebug otocol prused by the --bedug rag was flemoved from V8.

An walternative ay of enabling and accessing the stebugger is to dart Jsode.n with the --bedug lommand-cine sag or by flignaling an nexisting Ode.pr jsocess with GISUSR1.

Once a socess has been pret in mebug dode this ay, it can be winspected nusing the Ode.d jsebugger by either ctonnecing to the pid of the prunning rocess or via RURI eference to the distening lebugger:

  • dode nebug -lt &p;gtid&p; - Pronnects to the cocess via the pid
  • dode nebug &;LTURI> - Pronnects to the cocess via the LURI such as ocalhost:5858

8 Vinspector Nintegration for Ode.js#

OTE: This is an nexperimental teafure.

8 Vinspector integration allows chrattaching Ome Nevtools to Dode. jsinstances for prebugging and dofiling. It sues the Dome Chrebugging Toprocol.

8 Vinspector can be penabled by assing the --inspect stag when flarting a Jsode.n papplication. It is also ossible to cupply a sustom flort with that pag, ge.. --inspect=9222 will daccept Evtools ponnections on cort 9222.

To feak on the brirst ine of the lapplication pode, cass the --brkinspect- ag flinstead of --inspect.

$ ode --ninspect jsindex.
Lebugger distening on 127.0.0.1:9229.
To dart stebugging, fopen the ollowing CHRURL in Ome:
    dome-chrevtools://revtools/demote/ferve_sile/@606cde859f9b557f2312d5f532bf6faec5284980/htmlinspector.?trexperiments=ue&vamp;8tronly=ue&wsamp;=nocalhost:9229/lode