关于create-react-app([email protected])升级的坑

时间:2021-12-25 07:19:04

今天用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.  

                                       

 在package.json中你会看到react-scripts升级到了3.3.0,它不再支持全局安装CRA(create-react-app)。

查了一些资料,朋友们都说用npx create-react-app my-app可以,经过我不断试错,才发现前提是一定要先卸载全局CRA才能成功!

所以,卸载全局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 my-app