You are running
create-react-app
4.0.3, which is behind the latest
release (5.0.0). We no longer support global installation of Create
React App.
创建React时出现错误报告
如果遇到这样的情况:
原因是:
因为create-react-app是通过全局安装npm install -g create-react-app
的,而如今已经不再支持全局安装react项目,根据下图官网查到,首先需要卸载它以确保npx始终使用最新版本。
因此解决方案一:
卸载package全局配置
npm uninstall -g create-react-app
然后再使用NPX安装
npx create-react-app my-app
解决方案二:
或者卸载软件包
yarn global remove create-react-app
然后再使用NPX安装
npx create-react-app my-app
建议创建react项目的方法:
NPX
npx create-react-app my-app
NPM
npm init react-app my-app
yarn
yarn create react-app my-app