提问者:小点点

Create-React-App不创建入门模板


我正试图按照这些说明使用typescript模板创建一个新项目。

npx create-react-app app-ui --template typescript

尽管它安装了所有节点模块,但它既不创建starter项目,也不使用提供的模板。我得到这个信息:

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.

我正试图按照说明删除cli的全局安装,但这也不起作用:

 npm uninstall -g create-react-app
 up to date in 0.037s

无论我做什么,我都无法卸载cli。发生了什么事?

编辑:

我能够让它部分工作在PC上。

npm remove create-react-app

然后呢

npx create-react-app my-app [--template typescript]

我试着用括号,虽然模板项目在那里,但它不在打字稿中。现在cli有一些非常不对劲的地方。

编辑:

这篇文章解决了无法卸载cli的问题。希望这对某人有所帮助,请投票表决。


共3个答案

匿名用户

对于OP:

你的括号不合适。对于你的情况,留档文档说使用:

npx create-react-app my-app --template [template-name]  

npx create-react-app my-app --template typescript

对于其他人:

>

  • 卸载(我在Linux/Ubuntu上)

    sudo npm uninstall -g create-react-app
    

    然后运行:

    npx create-react-app my-app
    

    注意:确保卸载时删除了所有文件夹/文件。如果您无法像我一样访问linux设置中的反应文件夹(由于权限),请通过以下方式访问并删除:

    sudo chown -R $USER /usr/bin/create-react-app
    

    (…然后执行npx命令。)

  • 匿名用户

    我通过sudo npm uninstall-g create react app

    但这并没有删除CreateReact应用程序,所以我必须检查它所在的目录。在终端中,如果键入:

    创建react应用程序的程序

    它将为您提供一些目录,如/usr/local/bin/create-react-app-Now-do:

    rm -rf /usr/local/bin/create-react-app
    

    这将手动删除CreateReact应用程序。现在,您可以使用npx create react app my app

    匿名用户

    我也有同样的问题。这对我有用(Linux)

    步骤01。

    sudo npm remove create-react-app
    

    步骤02。

    sudo npm uninstall -g create-react-app
    

    步骤03。

    npx create-react-app my-app --template typescript
    

    我希望这能有所帮助。