创建react项目时,需要用到react-create-app脚手架,之前是全局安装的,全局安装后使用命令create-reacte-app my-app来创建项目,但是现在官方不建议全局安装的方式使用react-create-app,改用npx create-react-app my-app命令来创建项目
电脑上的create-react-app脚手架是之前全局安装的,创建项目时,报如下错误:
大概意思是当前create-react-app版本过低,让我卸载老版本,命令行给出了两条卸载命令:
npm uninstall -g create-react-app
yarn global remove create-react-app
用npm uninstall -g create-react-app执行卸载,提示如下:
卸载失败!
再用yarn global remove create-react-app执行卸载,提示如下:
还是失败!
输入create-react-app -V还能查到版本号,说明确实没能将其卸载掉:
解决方案:
使用where create-react-app命令查看其所在位置
然后手动删除这些create-react-app相关文件,删除之后我们在执行一下create-react-app -V
如图所示,create-react-app命令已经无法执行,说明create-react-app已被彻底清除
现在再来执行创建项目的命令npx create-react-app my-app
这时候可以看到可以正常创建项目了。
完。