An warware: An kasa warware dogaro%3A npm ERR%21 amsa takwaro%40%2217.0.1%22 daga amsa-dom%4017.0.1

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.

Shafi posts:

Leave a Comment