Tabbas, bari mu fara.
Saurin juyin halitta na fasaha yana kawo canje-canje a ci gaban software cikin sauri. A sakamakon haka, lura da duk fakitin software don kasancewa akan sabon sigar galibi ana ganinsa azaman aiki mai ban tsoro ga masu haษakawa. Koyaya, sabunta duk fakiti yana da mahimmanci don kwanciyar hankali, tsaro, da saurin aikace-aikacen gidan yanar gizo. A cikin JavaScript, kayan aiki masu ฦarfi daban-daban na iya sarrafa waษannan ayyuka da sauฦaฦe ฦwarewar gaba ษaya. A cikin wannan jagorar, za mu mai da hankali kan sabunta duk fakiti a cikin aikin JavaScript ta amfani da npm (mai sarrafa fakitin node), ษaya daga cikin manyan manajan fakitin gama gari a cikin yanayin yanayin JavaScript.
npm yana sauฦaฦa sarrafa fakiti don aikin a cikin tsari mai tsari. Koyaya, lokacin da aka haษa fakiti da yawa, bincika hannu da sabuntawa na iya zama mai gajiyarwa. Sa'ar al'amarin shine, npm yana ba da hanyoyi don duba fakitin da suka gabata da sabunta su gaba ษaya.
Ana ษaukaka fakiti tare da npm
Don sabunta duk fakiti:
- Da farko, tuna don buษe tashar tashar a cikin tushen littafin aikin ku.
- Sa'an nan, gudanar da umurnin
npm outdated
. Wannan zai nuna tebur a cikin tasha mai lissafin duk fakitin da suka tsufa, sigar yanzu da kuke da ita, sabuwar sigar da ake da ita, da sauransu.
- Na gaba, don sabunta duk fakitin zuwa sabbin sigar su, gudu
npm update
.
- A madadin, don sabunta takamaiman fakiti, yi amfani
npm install <package>@latest
.
Ka tuna, koyaushe gwada aikace-aikacenku sosai bayan sabuntawa don tabbatar da cewa komai yana aiki kamar yadda aka zata.
Amfani da Utilities don Sabunta Sauฦi
Akwai abubuwan amfani waษanda zasu iya sa tsarin sabunta fakitin ya fi sauฦi. Shahararren kayan aiki shine npm-duba-sabuntawa, aka sani da ncu. Don farawa da ncu:
- Na farko, mun shigar da shi a duniya tare da
npm install -g npm-check-updates
.
- Sa'an nan, za mu iya jera duk sabon dogara ga aikin ta gudu
ncu
.
- A ฦarshe, don sabunta duk fakitin, gudu
ncu -u
. Wannan yana haษaka fayil ษin ku na kunshin.json don amfani da sabuwar sigar kowane fakitin, sannan
npm install
don shigar da fakitin da aka sabunta.
Ka tuna, mai kama da sabuntawar npm, koyaushe tabbatar da ayyukan aikace-aikacen ku kamar yadda ake tsammani bayan sabuntawar.
Kula da Nau'in Dogara
Aikace-aikacen JavaScript yawanci suna da nau'ikan dogaro biyu - abin dogaro da kuma dogara. Ana buฦatar na farko don aikace-aikacen ya gudana, yayin da na ฦarshe kawai ake buฦata a cikin lokacin ci gaba. Lokacin sabunta fakiti, fahimtar waษannan abubuwan dogaro yana da mahimmanci don kiyaye aiki da kwanciyar hankali na aikace-aikacen ku.
Bari wannan jagorar ta zama taswirar hanya don tafiyarku don ฦwarewar fasahar sabunta fakiti. Tsarin na iya zama kamar abin ban tsoro da farko, amma tare da ษan aiki kaษan, ya zama yanayi na biyu. Murnar coding!