Fix the upstream dependency conflict installing NPM packages

文章推薦指數: 80 %
投票人數:10人

Fix the upstream dependency conflict installing NPM packages. Trying to npm install vue-mapbox mapbox-gl and I'm getting a dependency tree error. SkiptocontentTryingtonpminstallvue-mapboxmapbox-glandI’mgettingadependencytreeerror.I’mrunningNuxtSSRwithVuetify,andhaven’tinstalledanythingrelatedtoMapboxpriortorunningthisinstallandgettingthiserror.38errorcodeERESOLVE 39errorERESOLVEunabletoresolvedependencytree 40error 41errorWhileresolving:[1mexample[[email protected][1m1.0.0[22m 41errorFound:[1mmapbox-gl[[email protected][1m1.13.0[22m[2m[22m 41error[2mnode_modules/mapbox-gl[22m 41error[1mmapbox-gl[[email protected]"[1m^1.13.0[22m"fromtherootproject 41error 41errorCouldnotresolvedependency: 41error[35mpeer[39m[1mmapbox-gl[[email protected]"[1m^0.53.0[22m"from[1mvue-mapbox[[email protected][1m0.4.1[22m[2m[22m 41error[2mnode_modules/vue-mapbox[22m 41error[1mvue-mapbox[[email protected]"[1m*[22m"fromtherootproject 41error 41errorFixtheupstreamdependencyconflict,orretry 41errorthiscommandwith--force,or--legacy-peer-deps 41errortoacceptanincorrect(andpotentiallybroken)dependencyresolution. 41error 41errorSee/Users/user/.npm/eresolve-report.txtforafullreport. 42verboseexit1 What’stherightwaytogoaboutfixingthisupstreamdependencyconflict?connorcodeLookslikeit’saproblemwithPeerDependenciesinthelatestversionofnpm(v7)whichisstillabetaversion.trywithnpminstall--legacy-peer-depsfordetailinfocheckthishttps://blog.npmjs.org/post/626173315965468672/npm-v7-series-beta-release-and-semver-majorSultanMaulanaUse--legacy-peer-depsafternpminstall.Forexample,ifyouwanttoinstallradium,use:npminstall--legacy-peer-deps--saveradium TomerikooShivamYadavThereareTWOways:usenpminstall--legacy-peer-depstoinstall,andifthisdoesn’tworkuseforcemethod.add–forcenexttonpminstall:npminstall--forcejasiehatakekakashiuntilnpmversion7.19.1stillhavesameissue,afterupgradedtoversion7.20.3usecommandnpminstall-g[email protected]andnpmauditfixallpkgsfixedwithouterror.StupiCodeYoucanfollowthiscommandfirsttype:npmconfigsetlegacy-peer-depstrue thentype:npxcreate-react-appmy-app JakubKurdzielMdSajedulIslamToSolveFixtheupstreamdependencyconflictinstallingNPMpackagesErrorMethod1.JustUse–legacy-peer-depsafternpminstall.Forexample,ifyouwanttoinstallaxios,usenpminstall--legacy-peer-deps--saveaxios. Method2.UpdatingnpmandauditfixnpmI-g[email protected] npmauditfix--force Method3.using–forcetoinstallpackagesnpminstallaxios--force DharmanBotconfused_Toresolvenpmdependenciesandconflictswithnpmpackagesusenpm-check-updateshttps://www.npmjs.com/package/npm-check-updatesNatiKamusherdeletethepackage-lock.jsonfilemodifythepackage.json,updatingtheversionasindicatedbythepeerdependancyrunnpminstallornpmudpateMatoeilItriedmultiplewaysbutnothingwasworkingforme.Atlasttriedthisanditworkednpmconfigsetlegacy-peer-depstrueRunthisintheprojectfolderandthentrytoinstallanypackage.Mightworkforyouaswelluser15842079Ihavedowngradedmynodeversionto10.23.1itworkedfine.yogeshclAlotofupvotesforusing--legacy-peer-depsbutif--forceworksIwouldrecommendusingthatsinceitstillpinsmanydependencyversionswhile--legacy-peer-depsignorepeerdependenciesentirely.Seeexamplebelow:https://stackoverflow.com/a/66608842/3850405StartedgettingthiserroronAzureDevOpsafewdaysago.InitiallythoughtitwasaglitchonAzuresidebutsinceitcontinuedwestartedlookingintoitabitmore.Turnsouttheagentweareusing,windows-2022,wasupdatedafewdaysago.https://github.com/actions/virtual-environments/commit/2950cbfeab88a6a6202fa31d7371e574dbe2dc51NodeandNPMnowmatchtheLatestNode.jsLTSVersion:16.15.1(includesnpm8.11.0)https://nodejs.org/en/download/YoucanviewallagentsincludedSoftwarehere:https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#softwareAfterreadingonMicrosoftVisualStudioDeveloperCommunitytheyrecommenddowngradingNode.jsusingNode.jsToolInstallertasklikethis:-task:[email protected] inputs: versionSpec:'16.14.2' https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/node-js?view=azure-devopshttps://developercommunity.visualstudio.com/t/npm-install-fails-in-azure-devops-hosted-agent/1606509HoweverwedecidedthatwedonotwanttodowngradeNode.jssofirststepwasmatchingNode.jslocallywithLTSVersion:16.15.1andnpm8.11.0.Whenrunningnpmciwethengotthesameerrorlocally.Triednpmci--forceandwethengotthiserror:npmcicanonlyinstallpackageswhenyourpackage.jsonandpackage-lock.jsonornpm-shrinkwrap.jsonareinsync.Pleaseupdateyourlockfilewithnpminstallbeforecontinuing.npminstallgavethesameerrorevenafternode_moduleswasmanuallyremovedbutnpminstall--forceworkedanditgeneratedanewpackage-lock.json.npmcistillfailedwiththesameerrorbutrunningnpmci--forceworked.WedecidedtoupdateAzureDevOps.ymltoinclude--forceandcheckedinthenewpackage-lock.json.Afterdoingthiseverythingworkslikebeforeandwecannowupdateourpackagesonebyone.OgglasWhatishappeningisthatyourdependencymexamplerequiresmmapbox-glv1.13.0andmvue-mapboxrequiresv0.53.0.NPMdon’treallyknowwhattodo,soitgivesawarning.Youcanbypasstheerrorsusing--forceor--legacy-peer-depsbutyouareignoringanerror.ProductionOptions:Probablyoneofyourpackagesisoutdated.Upgradingpackagesandfixingupgradeerrorsmightfixthedependencyconflict.Overridingadependencymanuallytoavoidthewarninganderror.Whatyouaredoingissettingtheversiontoaspecificonethatyouknowthatworks.Usuallythenewerversion.Examplesolutionwithoverride.Yourpackage.jsonwilllooklikethat:{ "name":"my-app", "version":"0.1.0", "private":true, "dependencies":{ "mexample":"^1.2.0", "vue-mapbox":"*" }, "scripts":{ "start":"react-scriptsstart", "build":"react-scriptsbuild", "test":"react-scriptstest", "eject":"react-scriptseject" }, "overrides":{ "mmapbox-gl":"1.13.0" } } Thelastoptionisbypassingusingeither:--legacy-peer-depsIgnorescompletelyallpeerDependenciesusingthenewestversionwithoutpinningonpackage-lock.json--forceForcestheuseofthenewestpinningalltheversionsonpackage-lock.jsonExtra:Youshouldn’tuse“*”asaversionbecausemightupdatemajorandbreakdependencies.GustavoGarcialang-jsSourceTheanswers/resolutionsarecollectedfromstackoverflow,arelicensedunderccby-sa2.5,ccby-sa3.0andccby-sa4.0.PostnavigationPrevious PreviousHowtodoequivalentofLINQSelectMany()justinjavascriptNextContinue SetcustomHTML5requiredfieldvalidationmessageSimilarPostsreportthisadRelatedPostsreportthisad x



請為這篇文章評分?