关于create-react-app(react-scripts@3.3.0)升级的坑


今天用create-react-app my-app,看到下面的提示:

A template was not provided. This is likely because you're using an outdated version of create-react-app.

Please note that global installs of create-react-app are no longer supported.  

                                       

根据提示会看到是CRA(create-react-app)是过时的,且不再支持全局安装CRA。

查了些资料可以用npx,用npx有两种方法供参考:

1、你本地全局安装过CRA,如果使用npx create-react-app myApp,它依然用的是本地安装的过时的CRA,如果想使用远程模块,请使用

npx --ignore-existing create-react-app myApp

2、本地安装的CRA已经没有任何使用价值,可先卸载,再使用npx create-react-app myApp即可

  • 卸载全局CRA

npm uninstall -g create-react-app

但是发现卸不掉CRA,因为下面的command还可以拿到它的版本号:

create-react-app -V

->3.0.1


怎么办嘞?那就手动删除吧,执行下面的command:

 which create-react-app

->/usr/local/bin/create-react-app

rm -rf /usr/local/bin/create-react-app

 

create-react-app -V

-bash: /usr/local/bin/create-react-app: No such file or directory

删除成功!

  • 最后用npx就快速生成react项目,运行OK

npx create-react-app myApp


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM