• 解决create-react-app 后 npm start 中出现 的webpack版本问题和webpack-dev-server的版本问题


    利用VSCode搭建react的脚手架运行环境的时候。create-react-app之后npm start出现如下图的问题:

    There might be a problem with the project dependency tree.
    It is likely not a bug in Create React App, but something you need to fix locally.
    
    The react-scripts package provided by Create React App requires a dependency:
    
      "webpack": "4.19.1"
    
    Don't try to install it manually: your package manager does it automatically.
    However, a different version of webpack was detected higher up in the tree:
    
      C:Users17720
    ode_moduleswebpack (version: 4.25.1)
    (version: 2.9.1) Manually installing incompatible versions is known to cause hard-to-debug issues.

    在参考 https://blog.csdn.net/muzi190/article/details/84108714 之后,又出现如下的问题。。。:

    PS C:Users17720DesktopStudyReacthello> npm start
    
    > hello@0.1.0 start C:Users17720DesktopStudyReacthello
    > react-scripts start
    
    
    There might be a problem with the project dependency tree.
    It is likely not a bug in Create React App, but something you need to fix locally.
    
    The react-scripts package provided by Create React App requires a dependency:
    
      "webpack-dev-server": "3.1.14"
    
    Don't try to install it manually: your package manager does it automatically.
    However, a different version of webpack-dev-server was detected higher up in the tree:
    
      C:Users17720
    ode_moduleswebpack-dev-server (version: 2.9.1)
    
    Manually installing incompatible versions is known to cause hard-to-debug issues.

    解决办法:找到版本出问题的目录:如我的是

    C:Users17720
    ode_modules

    然后在该路径(这是全局路径)下卸载不符合版本的webpack 与 webpack-dev-server

    注意卸载webpack时还需要卸载webpack-cli ,4.0版本后的webpack都带有webpack-cli:

    npm un webpack
    npm un webpack-cli
    npm un webpack-dev-server

    然后再把提示报错的版本安装上,如:

    npm i webpack@4.19.1
    npm i webpack-cli
    npm i webpack-dev-server@3.1.14

    这时候再次npm start 就没出现问题啦

  • 相关阅读:
    Android开发环境下关于如何导出手机通讯录数据库【Written By KillerLegend】
    Win+R快速打开你的应用程序
    public void onItemClick(AdapterView arg0, View view, int position,long arg3)详解【整理自网络】
    Adapter的getView方法详解
    LayoutInflater中四种类型inflate方法的介绍
    程序员电脑桌面,哪一张触动了你?
    o​r​a​c​l​e​ ​O​D​B​C​配​置 图形界面
    C#String与string大小写的区别
    怎么使用FlashFXP上传网站
    C#操作Excel文件
  • 原文地址:https://www.cnblogs.com/donghezi/p/10234721.html
Copyright © 2020-2023  润新知