Farawa daga ainihin yanayin ci gaban Node.js, zurfafa zurfafa cikin duniyar coding na iya kawo wasu kurakurai da ke barin mu a tsaka-tsaki. ฦayan irin wannan kuskuren shine sananne ERR! code ELIFECYCLE npm ERR! kuskure 2, wanda sau da yawa yana faruwa lokacin aiwatar da rubutun ta amfani da NPM a cikin yanayin Node.js.
Wannan kuskuren yana tasowa ne ta hanyar gazawar aikin Node.js don aiwatar da rubutun gininsa daidai. Fuskantar irin wannan kuskuren a tsakiyar aiwatar da aikace-aikace mai mahimmanci na iya zama mai takaici sosai kuma yana haifar da cikas ga ci gaba. Koyaya, kada ku ji tsoro, saboda ana iya gyara wannan tare da ษimbin umarni da aka tsara daidai.
Hanyar ฦaddamarwa
Yawancin lokaci, lokacin da muka haษu da ERR! code ELIFECYCLE npm ERR! errno 2, yana da mahimmanci don tsaftace cache npm ta hanyar aiwatar da umarnin `
npm cache clean --force
`. Buga wannan, mataki na gaba shine share babban fayil 'node_modules' tare da fayil 'package-lock.json'. Da zarar an cire waษannan, sake shigar da aikin ta amfani da npm na iya magance matsalar.
Yin nazarin Magani
Maganin wannan matsala shine ainihin mai sauฦi. A mataki na farko, lokacin da kake gudanar da umarni `
npm cache clean --force
`, abin da ke faruwa da gaske shine npm yayi aiki da umarnin ku don share cache ษin sa. Wannan yana nufin cire duk bayanan da ya kasance yana adanawa akan tsarin ku wanda ya shafi fakitin da aka shigar da nau'ikan su.
Bayan haka, muna share kundin adireshin 'node_modules' da fayil 'package-lock.json'. Anan ne npm ke shigar da abubuwan dogaro da aikin, kowanne a cikin babban fayil ษin sa. Ana samar da fayil ษin 'kunki-lock.json' ta atomatik don kowane aiki inda npm ya canza ko dai 'node_modules' directory, ko 'package.json' kuma an yi niyya don kulle nau'ikan abubuwan dogaro na kunshin.
Mataki na uku, reinstallation, da gaske sake zazzage abubuwan dogaro kuma yana gyara yanayin da ya karye.
Laburaren da suka dace da Ayyuka
Fahimtar mai amfani da npm da yanayin Node.js yana da mahimmanci don warware wannan batu. Wannan mawuyacin sau da yawa yana tasowa saboda bambance-bambance ko rashin aiki a cikin abubuwan dogaro da aka shigar, don haka yana da mahimmanci a bincika 'npm`kuma`Node.js`- bangarorin biyu na wannan maganin.
- NPM (Mai sarrafa fakitin Node) yana goyan bayan al'ummar Node.js ta hanyar samar da ingantaccen bayani don shigar da fakiti, sarrafa dogaro, da sarrafa sigar. Yana daidaita tsarin haษa kayan aikin ษangare na uku da kayayyaki a cikin aikace-aikacen ku.
- Node.js, a gefe guda, buษaษษen tushe ne, yanayin lokaci na lokaci mai tsawo na JavaScript. An ฦirฦira ฦirar sa akan tsarin gine-ginen da ke tafiyar da taron JavaScript wanda ke ba da izinin asynchronous, nau'in aiki mara toshewa. Wannan sifa ta sa Node.js ya zama babban ษan takara don aikace-aikacen ainihin lokaci.
Fuskantar ERR! code ELIFECYCLE npm ERR! errno 2 bai kamata ya zama babban abin tsoro ga masu haษakawa ba - da zarar an fahimci dalilin matsalar, ana iya aiwatar da mafita cikin sauฦi, kuma tsarin ci gaba zai iya ci gaba da tasiri ba tare da tsangwama ba.