Tabbas, bari mu fara da batun da ke hannunmu.
NPM (Mai sarrafa fakitin Node) kayan aiki ne mai ban mamaki wanda ke sarrafa abubuwan dogaro da ayyukan ku. Koyaya, wani lokacin yana iya jefa kurakurai waษanda ba a bayyana nan da nan ba. ฦayan irin wannan kuskuren gama gari shine kuskuren dogaro na tsara, musamman: `Ba a iya warware dogaro: npm ERR! peer react@"17.0.1" daga amsa-dom@17.0.1'
Wannan kuskuren na iya bayyana lokacin da kuke ฦoฦarin shigar da fakitin da ke da abin dogaro na takwarorinsu waษanda ba a cika su ba a cikin aikinku na yanzu. Ainihin, fakitin da kuke ฦoฦarin shigarwa yana tsammanin wasu nau'ikan sauran fakitin an riga an shigar dasu. A wannan yanayin, sigar react-dom 17.0.1 tana neman takwarorinsu na react version 17.0.1.
Yanzu, bari mu nutse cikin maganin wannan matsala, sannan mu ci gaba da yadda ake aiwatar da ita a sashin bayanin matakin mataki-mataki.
Magani ga Kuskuren Dogarowar Tsari
Maganin yawanci ya ฦunshi shigar da daidaitaccen sigar dogaron takwarorinsu, a wannan yanayin React. Don wannan, za mu yi amfani da ษayan sabbin fasalulluka na npm, umarnin `โlegacy-peer-deps`.
Ana amfani da wannan umarnin lokacin shigar da fakiti, kuma yana gaya wa npm don yin watsi da abin dogaro na tsara kuma a ci gaba da shigarwa. Ga yadda ake amfani da shi:
npm install --legacy-peer-deps
Yin amfani da wannan umarnin, npm zai shigar da abubuwan dogaro kamar yana amfani da sigar da ke ฦasan npm 7, inda masu dogaro da ฦwararru ba su da ฦarfi.
Bayanin Code-by-Taki-Taki
Da zarar kun gudanar da umarni tare da `โlegacy-peer-deps`, npm zai fara aikin shigarwa. Tsarin shigarwa yana duba fayil ษin kunshin.json na fakitin da kuke ฦoฦarin shigarwa. Idan ba a cika nau'ikan abin dogaro na tsara da ake buฦata ba, yawanci npm zai jefa kuskure.
Koyaya, tare da `โlegacy-peer-deps`, npm yayi watsi da waษannan abubuwan dogaro na takwarorinsu ba tare da ci gaba da shigarwa ba.
npm install react-dom@17.0.1 --legacy-peer-deps
Wannan lambar za ta shigar da nau'in 17.0.1 na react-dom, yin watsi da abin da ake bukata na dogaro da tsara.
Fahimtar NPM, Dakunan karatu da Jagoran Ayyuka
NPM tsarin yanayin fakitin kyauta ne mai buษewa don JavaScript, ana amfani da shi da farko don shigarwa da sarrafa samfuran waje ko fakiti. Fakitin npm na yau da kullun ya ฦunshi fayil ษin 'package.json'. Wannan fayil ษin ya ฦunshi metadata game da fakitin kamar sunansa, sigarsa, bayaninsa, bayanin marubuci, da ฦari.
Laburaren cikin JavaScript da gaske su ne guntun lamba da za a sake amfani da su. Suna ceton masu haษakawa daga rubuta wasu tubalan lamba duk lokacin da ake buฦatar su.
Aiki, a gefe guda, wani toshe ne na lambar da za a sake amfani da shi wanda ke yin wani aiki. Yana iya karษar abubuwan shigarwa kuma ya dawo da fitarwa. An ayyana aiki a cikin JavaScript tare da kalmar maษalli na aiki, sannan suna biye da ita, sannan da baka ().
- Matsalolin dogaro da ฦwararru yawanci na faruwa lokacin da sigar fakitin da ake buฦata ba daidai ba ne, ko kuma ba a shigar da ita ba. An ฦayyade wannan sigar a cikin fayil ษin package.json.
- Yin amfani da tutar `โlegacy-peer-deps` a cikin umarnin npm yana ba masu haษaka damar ketare wannan kuskure.
Lura cewa ci gaba, kuna son tabbatar da cewa an shigar da daidaitattun nau'ikan fakitin kamar yadda masu haษakawa suka ayyana don guje wa yuwuwar al'amuran ayyuka daga baya.