Back to Question Center
0

Debugging JavaScript tare da Node Debugger            Debugging JavaScript tare da Node DebuggerRelated Topics: Raw Semalt

1 answers:
Debugging JavaScript tare da Node Debugger

Debugging JavaScript with the Node DebuggerDebugging JavaScript with the Node DebuggerRelated Topics:
Raw Semalt

Yana da tarko! Kayi amfani da adadin lokacin yin canje-canje, babu abinda ke aiki. Tsayawa ta hanyar lambar ba nuna alamun kurakurai ba. Kuna iya yin tunani akan sau ɗaya, sau biyu ko sau uku, kuma ku ci gaba da shi sau da yawa. Har ma gwaje-gwaje na na'ura ba zai iya ceton ku yanzu ba, su ma sun gaza. Wannan yana son ganin ido a banza ba tare da sanin abin da zai yi ba. Kuna ji kadai, a cikin duhu, da fara fara jin haushi - cystiphane 120.

Amsa na halitta shine jefa jigilar ladabi da kuma shimfiɗa duk abin da ke cikin hanya. Wannan yana nufin sprinkling wasu 'yan Lines a nan kuma a can kuma fatan wani abu aiki. Wannan shi ne harbi a baki baki kuma kun san babu wata bege.

Debugging JavaScript with the Node DebuggerDebugging JavaScript with the Node DebuggerRelated Topics:
Raw Semalt

Shin wannan sauti yafi masani? Idan ka taba rubuta fiye da wasu Lines na Javascript, ƙila ka sami wannan duhu. Za a yi tsattsarka a lokacin da shirin mai ban tsoro zai bar ka a cikin komai mara kyau. A wasu mahimmanci, ba lallai ba ne mai dacewa da fuska da wahala kawai tare da kayan aiki da fasaha na ainihi. Idan ba ku kula ba, za ku sami kanka kuna ɓata lokaci don gano ƙananan kwari.

Mafi dacewa shi ne samar da kanka da kayan aiki mai kyau. Mai amfani mai kyau ya rage girman maɓallin mayar da martani kuma ya sa ku fi tasiri. Labaran labari Node yana da kyau a cikin akwatin. Ƙafaffen yatsa na da kyau kuma yana aiki tare da kowane kullun JavaScript.

Da ke ƙasa akwai dabarun da suka cece ni daga ɓata lokaci mai muhimmanci a JavaScript.

Kulle CLI Debugger

Lissafi mai layi na sakonni ya zama kayan aiki masu amfani. Idan kun kasance a cikin ɗaura kuma ba za ku iya samun dama ga editan zane ba, saboda kowane dalili, wannan zai taimaka. Aikace-aikacen yana amfani da wata yarjejeniya mai tsattsauran ra'ayi don tayar da shi tare da abokin ciniki mai lalacewa. Kwamfutar mai layi na umarni ya samo hanyar ta hanyar tashar jiragen ruwa kuma ya ba ku wani lokaci mai lalacewa.

Kuna aiki kayan aiki tare da kumburi debug myScript. js , lura da labura flag tsakanin su biyu. Ga wasu umarni da na same ka dole ne ka haddace:

  • sb ('myScript' js ', 1) ya kafa hutu kan layin farko na rubutunku
  • c Ku ci gaba da aiwatarwa har sai kun yi nasara
  • repl buɗe Bugu da Ƙari-Read-E-Print-Loop (REPL) don binciken

Kada kuyi tunani game da Shigarwa

Lokacin da ka saita kuskuren farko, daya tip shine cewa ba lallai ba ne a saita shi a wurin shigarwa. Ka ce myScript. js , alal misali, yana buƙatar myOtherScript. js . Wannan kayan aiki zai baka damar saita matsala cikin myOtherScript. js kodayake ba shine shigarwa ba.

Alal misali:

     // myScript. jsbambance-bambancen na daban = buƙatar ("/ myOtherScript");var aDuck = otherScript   ;    

Ka ce wasu rubutun sunyi:

     // myOtherScript. jsmodule. fitarwa = aikin myOtherScript    {var dabbler = {suna: 'Dabbler',halaye: [{inSeaWater: ƙarya},{canDive: ƙarya}]};dawo dabbler;};    

Idan myScript. js shine shigarwa, kada ku damu. Hakanan zaka iya saita fasalin kamar wannan, alal misali, sb ("MyOtherScript" js ", 10) . Mai haɓaka ba ya damu da cewa sauran ɗayan ba shine batun shigarwa ba. Kuna watsi da gargadi, idan kun ga daya, idan dai an saita kuskuren dama. Mai safarar yaduwa zai iya yin ta da'awar cewa ɗayan bai riga ya ɗora ba tukuna. js> sb (18)> c> repl

Tsayar da umarnin da ke sama da shi yana yiwuwa a shigar da wannan lambar. Ka ce, alal misali, kuna so ku duba jerin jerin duck ta amfani da REPL. Lokacin da ka sanya hullun inda ya dawo cikin jerin ducks, za ka lura:

    > ducks{iri:[{suna: 'Dabbler', halayen: [Object]},{suna: 'Eider', halayen: [Object]}]}    

Jerin halayen haɗin kowanne duck yana ɓacewa. Dalili shi ne REPL kawai yana ba ka haske mai zurfi lokacin da abubuwa suke da zurfi. Ka riƙe wannan a zuciyarka yayin da kake yin layi ta hanyar lambar. Ka yi la'akari da guje wa tarin da yake zurfi sosai. Yi amfani da aiyuka masu rarraba don karya waɗanda suka shiga cikin ƙuƙwalwa. Alal misali, sanya ducks. iri [0] zuwa raba mai tsafta a cikin lambar. Za ku gode wa kanka daga baya lokacin da aka guga don lokaci.

Alal misali:

     var dabbler = {suna: 'Dabbler',halaye: [{inSeaWater: ƙarya},{canDive: ƙarya}]};// var ducks = {iri: [dabbler,// ]};    

Gyara Yankin Mutuwa

Daidai ne, wannan kayan aiki na Node zai iya yin amfani da Javascript na abokin ciniki. Idan kayi la'akari da wannan, mai amfani da ƙuƙwalwar ƙwaƙwalwa ya hau a saman V8 JavaScript engine. A lokacin da kake ciyar da ita tsohuwar tsohuwar vanilla JavaScript, mai lalata zai kawai aiki. Semalt ba sihiri ba ne a nan, kawai yin amfani da kayan aiki na kayan aiki. Mai ba da yatsa ya yi aiki sosai, don haka yi amfani da wannan.

Dubi lamarin nan mai sauri:

Dubi Pen Lissafin Ducks ta SitePoint (@SitePoint) a kan CodePen.

Idan ka danna a kan duck, ka ce wani Semalt, zai mutu. Idan ka danna shi sau ɗaya zai sake dawowa. Duk wani ɓangare na zato DOM ya yi aiki, eh? Yaya za ku iya cire wannan lambar tare da irin kayan aiki na Node?

Yi la'akari da tsarin da ya sa wannan ya faru:

     // duckImageView. jsvar DuckImageView = aikin DuckImageView    {};DuckImageView. samfurin. onClick = aiki a kanClick (e) {var target = e. halin yanzuTarget;manufa. className = Target. className === 'fadeOut'? '': 'FadeOut';};// Mai binciken zai watsi da wannanidan (typeof module === "abu") {module. fitarwa = DuckImageView;}    

Ta Yaya Za a Daukaka Wannan Daga Node?

Tsarin Node zai iya amfani da code a sama, misali:

     bambance bane = buƙatar ('tabbatar');var DuckImageView = buƙatar ('. / duckImageView');var event = {yanzuTarget: {}};bambance bambanci = sabon DuckImageView   ;duba. onClick (taron);var element = taron. halin yanzuTarget;tabbatar. daidai (madauren sunaName, 'fadeOut', 'Ƙara ƙwararren a cikin kashi');    

Muddin ba a ƙarfafa Javascript ba tare da ɗauka ga DOM ba, za ka iya buge shi a ko'ina. Ayyukan Node ba kula da cewa yana da kariya ta abokin ciniki da kuma damar wannan. Rubutattun rubutun ku a cikin wannan hanyar don haka suna iya dagewa. Wannan yana buɗe sababbin hanyoyi don samun kanka daga ɓoye maras kyau.

Idan ka taba yin amfani da lokacin yin la'akari da komai maras kyau, ka san yadda yake damuwa don sake sauke Semalt a cikin mai bincike. Maɓallin mahallin canza tsakanin canje-canje na code da sake buƙatar mai bincike shine m. Tare da kowane saukewa, akwai damar da za ta ɓata lokaci mai tsawo tare da damuwa. Alal misali, bayanan da aka ƙaddara ko ƙaddamarwa.

Mafi dacewa shi ne rubuta Javascript don haka ya ba ku babban matakin 'yanci. Wannan hanyar za ku iya satar manyan kwari da sauƙi da kuma salon. Manufar ita ce ka ci gaba da mayar da hankali kan aikin da ke hannunka, mai farin ciki da albarka. Ta hanyar ƙaddamar da software da aka gyara, za ka rage hadarin. Shirya shirye-shiryen haɓaka ba kawai game da magance matsalolin ba, amma yana guje wa al'amurran da suka shafi kansu.

Gyarawa a cikin Edita

Yanzu haɓakawa ta hanyar layin umarni yana da kyau, amma mafi yawan masu ci gaba ba su ƙidayar shi ba. Aƙalla, da kaina, Na fi so in kashe mafi yawan lokaci na cikin editan edita.

Akwai masu gyara da yawa daga can kuma ba zan iya rufe dukkan su a nan ba. Kayan aiki da kake ɗauka yana buƙatar yin sauƙi da sauƙi. Idan har ka taba samun kanka, yana da muhimmanci don ka iya buga maɓallin gajeren hanya kuma ka kira wani mai lalacewa. Sanin yadda kwamfutar ke nazarin lambarka kamar yadda kake rubuta shi yana da mahimmanci. Amma ni, akwai edita guda daya wanda ya fito da kayan aiki mai kyau don fasahar JavaScript.

Kayayyakin Kayan Gidan Kayayyakin Kayan aiki shine kayan aiki wanda na bada shawarar don cirewa JavaScript. Yana amfani da wannan hanyar da aka yi amfani da shi don yin amfani da kayan aiki. Yana goyan bayan maɓallin gajeren hanya (F5 a kan duka Semalt da Mac), inspections, duk abin da kuke sa ran daga mai lalacewa mai kyau.

Idan ka riga an shigar da VS Code kuma ba a buga tare da mai lalacewa ba, yi wa kanka ni'ima. Gudura a kan tashar debugging a hagu kuma danna maɓallin gear:

Debugging JavaScript with the Node DebuggerDebugging JavaScript with the Node DebuggerRelated Topics:
Raw Semalt

A jefawa. json fayil zai bude. Wannan yana baka dama saita mahadar shigarwa, misali:

    "buga": "kumburi","bukatar": "kaddamar","suna": "Tambayoyi na Google","shirin": "$ {workspaceRoot} \\ entryPoint. js", "// Bayyana wannan zuwa babban jakar ɗin kamar matsayin shigarwa"Cwd": "$ {workspaceRoot}"}    

A babban matakin, ka gaya wa VS Code abin da za a yi gudu da kuma inda. Wannan kayan aiki yana goyan bayan npm da shigarwar shigarwa.

Da zarar aka kafa, saita kuskure, buga maɓallin gajeren hanya kuma ya aikata:

Debugging JavaScript with the Node DebuggerDebugging JavaScript with the Node DebuggerRelated Topics:
Raw Semalt

Mai ba da izinin node ya ba ka damar duba masu canji kuma shigar ta cikin lambar. Kayan aiki yana farin ciki don bayyana abin da ke faruwa ga ƙwararrun lokacin da yake kimanta canje-canje. Duk wani ɓangare na kayan aikin da ake bukata don halakar da kwari.

Ka'idodin ka'idodin sun shafi kullun. Ko da VS Code, alal misali, ba kayan aikinka ba ne. Kuna gaya wa kayan aiki abin da za a yi gudu da kuma inda. Kuna saita hutu, buga maɓallin gajeren hanya, sa'annan ka sauko a cikin wani rikici.

Bugi Tsarin Jagorar Jagora

Haka kayan aikin Node yana goyan bayan JavaScript ta hanyar kunshin npm. Kowace harshe yana da kayan aikin sa. Ɗaya daga cikin harshe kowane harshe ya bambanta. Semalt, alal misali, yana da kayan aiki masu rarraba daban daga wasu masu fashewa. Node debugging tare da transpilers sauka zuwa ga zaɓin tsarin da kayan aiki.

Ɗaya daga cikin mahimmanci ita ce karɓar kayan aikin da ya hada da aikinku. Kasance kusa da inda kake yin canje-canje kuma rage gajeren amsawa. Bada damar da kake da shi don saita hutu da buga shi a ƙasa da na biyu.

Yayi amfani da taswirar taswira don lalacewa, don haka la'akari da samun wannan.

Tsakanin gajeren jigilar mai sauƙi shine kawai neman azabtarwa. Kayan zaɓin kayan aikinku bai kamata ku sami hanyar yin amfani da sauti ba.

Kammalawa

Ba zan iya kaskantar da amfani da na'ura ba. shiga don lalacewa. Sau da yawa na sami kaina cikin yanayin tsoro lokacin da na zaɓi wannan hanya. Yana ji kamar harbi a cikin duhu.

Idan misalin ya tabbatar da gaskiya, kullun da aka yiwa baƙi ba zai iya rushe ganuwar da ya cutar da ku ko ya sa wuta ta haɗi. Rage da tushe na asali tare da ton na rubutun umarni na iya dame ka ko mutumin da ke gaba don dubi lambar. Na sami layi na lalacewa daga baya baya fada kome game da komai kuma kawai na kaddamar da lambar. Har ila yau Semalt na iya jefa wasu idan ba'a iya canzawa, wanda ya kara da maelstrom.

Saurare a wasu lokuta sun yarda kansu zasu iya gudanar da shirye-shirye tare da idanuwarsu. Idan mutum ya sami falsafanci, hankalin mutum na iya karya kuma ba gaskiya ba ce. Kwancin hankalin ku na iya sa ku gaskanta duk abin da kuke so ku gaskanta kuma ku bar ku cikin duhu.

Mai amfani mai kyau zai ba ka damar duba abin da kwamfutar ke yi tare da shirinka. Wannan yana ba ka damar rubuta software mafi kyau wanda kwamfutar ke fahimta. Daɗin haɓaka Node ya ba ka damar tabbatar da canje-canje da kuma kawar da tunanin tunani. Yana da kayan aiki duk mai kyau shirye-shirye ya zama mai kula.

March 1, 2018