首页 > 编程知识 正文

webpack react,webpack最新版本

时间:2023-05-04 23:22:21 阅读:126463 作者:4950

第一天学习React,使用Create React App创建项目时遇到了一些问题,请记录下来。

问题说明webstorm使用npx创建- react-app my-app创建项目

npm start期间发生错误:

webpack版本问题webpack-dev-server版本问题new-appgit: (主控) ) ) ) ) ) ) ) ) )。 npmstartnew-app @0.1.0start react-scriptsstarttheremightbeaproblemwitheprojectdependencytree.itislikelynotabugincration y.the react-scriptspackageprovidedbycreatereactapprequiresadependency 3360 ' web pack-dev-dev-1.1 ' don ' trytoinstoinstall tomatically.However,adifferentversionofwebpack-dev-serverwasdetectedhigherupinthetree :/users/Roger Qian/node manuallyinstallingincompatibleversionsisknowntocausehard-to-debug issues.ifyouwouldprefertoignorethischeck, add skip _ preflight _ check=true toan.envfileinyourproject.thatwillpermanentlydisablethissagebutyoumightencounterourothect tryfollowingthestepsbelowintheexactorder :1.delete包- lock.JSON (not包. JSON! ) and/or yarn.lockinyourprojectfolder.2.delete node _ modulesinyourprojectfolder.3.remove ' web pack-dev-server ordevdepeper older.4.runNPMinstallorYarn,dependingonthepackagemanageryouse.in most cases,thisshouldbeenoughtofixtheproblem.ifthinaghed thereareafewotherthingsyoucantry :5.ifyousednpm, 安装yarn (http://yarn pkg.com/andrepeattheabovestepswithitinstead.thismayhelpbecausenpmhasknownissueswithpackagehoistingwhichmaygetresolvedinfutureversionsiongutureverersionononionionion Roger Qian/node _ modules/web pack-dev-serverisoutsideyourprojectdirectory.for example, youmighthaveaccidentallyinstalledsomethinginyourhomefolder.7.tryrunningnpmlswebpack-dev-serverinyourprojectfolder.thh expectedreact-scripts )安装的web pack-dev-server.ifnothingelsehelps, add skip _ preflight _ check=true toan.envfileinyourproject.thatwouldpermanentlydisablethispreflightcheckincaseyouwanttto 在出现webpack错误之前,没有记录上述webpack-dev-server版本问题

最终解决方案把光盘放在全球目录上,比如我的

Users/rogerqian/node_modules

卸载web包和web包-CLI和web包-dev-server

npmunwebpacknpmunwebpack-clinpmunwebpack-dev-server将根据以前在终端上报告的错误提示安装相应的版本。 我的React是17.0.2,对应的版本如下

npmiwebpack @4. 44.2 npmiwebpack-clinpmiwebpack-dev-server @3. 11.1然后可以通过npx create-react-app成功启动

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。