Unable to resolve dependency tree error in Angular while ...

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

To fix Unable to resolve dependency tree error in Angular while installing `npm` packages follow the below steps. 1. AngularWiki FlexLayoutAngularlCLIMaterialDesignPipesHttpClientFontAwesomeAngularJobs UnabletoresolvedependencytreeerrorinAngularwhileinstallingnpmpackagesFixingUnabletoresolvedependencytreeerrorinAngularArunkumarGudelliLastupdatedon Aug17,2022 3minreadTofixUnabletoresolvedependencytreeerrorinAngularwhileinstallingnpmpackagesfollowthebelowsteps.Runnpminstall--save--legacy-peer-depsinsteadofnpminstallcommand.Anotherwayisdeletenode_modulesfolderandpackage_lock.jsonfileandthenrun npmcacheclean--forceafternpmi--forcecommand.TableofContentsSetthe--legacy-peer-depsflagtoalwaystrueDowngradingnpmversionWhatisUnabletoresolvedependencytreeerror?It’sadependencyconflict(incorrectandpotentiallybrokendependency)error,sorunthecommandwith--forceor--legacy-peer-depsflag.npminstall--save--legacy-peer-deps or npmcacheclean--force npmi--force AnothertemporarysolutionisusingpriorversionsoftheNode.jsordowngradingnpm.Setthe--legacy-peer-depsflagtoalwaystrueAndinsteadofpassing--legacy-peer-depsflageachtimewecansetthenpmconfigtotrue.npmconfigsetlegacy-peer-depstrue Thencleanthecacheandrunnpminstallnpmcacheclean--force npminstall Thisthebestoptionifnpminstallisrunindirectly,i.e,byascript.DowngradingnpmversionWhenusingnpm7,Unabletoresolvedependencytreeerrorscomesupalotbecausepeerdependenciesissuesaretreatedaserrorsinversion7.Buttheseerrorsareonlywarningsinversion6.Sotoresolvethiserrorset--legacy-peer-depsflagtotrueinnpm7version.Iftheaboveconfigisnotworking,downgradenpm7tonpm6.DowngradingNode.jsisnotnecessary.Becausetherelevantdependencymanagementcodeisinnpm.DowngradingNode.jswilloftenworkautomatically,becausedoingsowilldowngradenpmaswell.Insteadofdowngradingnpm,usenpxtousethepreviousversionofnpmforjusttheinstallcommandasshownbelow.npx-pnpm@6npminstall WhatisUnabletoresolvedependencytreeerror?HereisthesampleunabletoresolvedependencytreeerrorinAngular.npmERR!ERESOLVEunabletoresolvedependencytree npmERR! npmERR!Whileresolving:[email protected] npmERR!Found:@angular/[email protected] npmERR!node_modules/@angular/common npmERR!@angular/common@"11.0.3"fromtherootproject npmERR! npmERR!Couldnotresolvedependency: npmERR!peer@angular/common@"^9.1.0||^10.0.0"from@agm/[email protected] npmERR!node_modules/@agm/core npmERR!@agm/core@"3.0.0-beta.0"fromtherootproject Firstwewillunderstandtheproblem.Intheaboveerror@agm/[email protected]@angular/commonversion^9.1.0or^10.0.0.Andtheactual@angular/commonversion11.0.3.Theproblemisaboutpeerdependencies.SoThesolutionistodowngrade@angular/common.Andthat’snotadvisable.Souselegacydependencieslogicforinstallingpackagesusing--legacy-peer-deps.Andtoinstalllegacypeerdependenciesautomaticallysetthenpmconfig--legacy-peer-depstotrue.npmconfigsetlegacy-peer-depstrue ⭐PleasestarAngularWikionGitHub!↗Likedthispost?SubscribeLet'sgoArunkumarGudelliIamOneamongamillionSoftwareengineersofIndia.Iwritebeautifulmarkup.ImaketheWebuseful.NextHowtodetect@inputvaluechangesinAngularChildComponent?PreviousHowToalignmat-dialog-actionsbuttonstotheright,centerorleft



請為這篇文章評分?