收藏从未停止,学习从未开始
react脚手架创建项目
时隔一年,中间虽参与过几个react项目,但是一直没机会从0创建项目开始。后一直致力于vue的开发,所以暂时放下了react。
至今,闲暇之余本想着重新温习一下react,但在创建项目的时候发现一个问题,特此记录。
使用脚手架命令创建项目:
create-react-app pro_name
提示了以下信息:
You are running `create-react-app` 4.0.2, which is behind the latest release (4.0.3).We no longer support global installation of Create React App.Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-appThe latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
可以看到,这么一句话:We no longer support global installation of Create React App.我们不再支持全局安装Create React App。
然后推荐卸载已全局安装的react脚手架。查看官网可知,和npm版本有关
查看npm版本:
npm -v

我的npm版本是 6.14.4
当npm版本 >= 5.2的时候,不能全局安装脚手架,需使用 npx create-react-app my-app进行创建项目
当 npm版本 < 5.2,则需全局安装脚手架,使用create-react-app pro_name进行项目创建
如果npm>= 5.2 且使用上述指令依旧报上述错误,可尝试以下指令:
npx create-react-app@latest my-app



















