create-react-app创建项目失败的解决方法

直接在目录下cmd然后create-react-app,报错:create-react-app创建项目失败的解决方法

解决方法,以管理员身份运行cmd,再create-react-app,不报错了,但是依旧有问题:

create-react-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.

可以看到create-react-app生成的目录是不完整的

create-react-app创建项目失败的解决方法

原因是create-react-app版本太旧。

解决方法:

删除旧版create-react-app,重新安装create-react-app,如下:

create-react-app创建项目失败的解决方法

create-react-app创建项目失败的解决方法

然后再用create-react-app新建项目就成功了:

create-react-app创建项目失败的解决方法create-react-app创建项目失败的解决方法

总结:想要create-react-app创建新项目,

①必须以管理员身份运行cmd

②create-react-app必须是新版,否则生成目录不完成,许需要卸载create-react-app后重装新版。