Reactjs 使用create react应用程序未提供模板

Reactjs 使用create react应用程序未提供模板,reactjs,create-react-app,Reactjs,Create React App,当我在终端中键入create react app my app命令时,该命令似乎起作用-成功下载所有库等。但在该过程结束时,我收到一条消息,表示未提供模板 输入 输出 Creating a new React app in /Users/user/Desktop/my-app. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts... .

当我在终端中键入
create react app my app
命令时,该命令似乎起作用-成功下载所有库等。但在该过程结束时,我收到一条消息,表示未提供
模板

输入

输出

Creating a new React app in /Users/user/Desktop/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
..... nothing out of the ordinary here .....
✨  Done in 27.28s.

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.
在我的应用程序的package.json中:

"dependencies": {
  "react": "^16.12.0",
  "react-dom": "^16.12.0",
  "react-scripts": "3.3.0" <-- up-to-date
}
“依赖项”:{
“反应”:“^16.12.0”,
“react dom”:“^16.12.0”,
“反应脚本”:“3.3.0”
  • npm安装-g在电脑中创建react应用程序
  • 使用npx create react app my app再次创建react项目
  • 如果您以前通过
    npm install-g create react app
    全局安装了
    create react app
    ,建议您使用
    npm uninstall-g create react app
    卸载软件包,以确保
    npx
    始终使用最新版本

    使用以下任一命令:

    • npx创建反应应用程序我的应用程序
    • npm init react app my app
    • 纱线创建反应应用程序我的应用程序
    如果上述npm卸载-g create react app
    无效。
    键入创建react应用程序的
    以了解其安装位置。我的安装在
    /usr/bin
    文件夹中。然后执行
    sudo rm-rf/usr/bin/create react应用程序
    (请参见下面的@v42注释)

    以添加以上答案:

    使用新发布的
    create react app
    ,您可以使用自定义模板创建新应用。 目前有两个模板可用:

    • cra模板
    • 模板类型脚本
    用法

    npx create-react-app my-app [--template typescript]
    
    create react app
    中最新更改的更多详细信息:

    "dependencies": {
      "react": "^16.12.0",
      "react-dom": "^16.12.0",
      "react-scripts": "3.3.0" <-- up-to-date
    }
    

    我也有同样的问题。当我trid
    npm init react app my app
    命令时,返回了相同的消息

    未提供模板。这可能是因为您正在使用 create react应用程序的过期版本

    但是

    纱线创建反应应用程序我的应用程序
    命令运行良好。

    这对我来说很有效

  • npm卸载-g创建反应应用程序
  • npx创建反应应用程序我的应用程序

  • 使用此命令后:

    yarn global upgrade create-react-app
    
    npm uninstall -g create-react-app
    
    npm uninstall -g create-react-app
    
    npm uninstall -g create-react-app
    
    然后我试着:

    yarn create-react-app my-app but it didn't work for me.
    
    尽管如此,这还是奏效了:

    npx create-react-app my-app 
    
    “如果您以前通过npm install-g create react app全局安装过create react app,建议您使用npm uninstall-g create react app卸载包,以确保npx始终使用最新版本”

    这是在上报告的。对我来说,这不起作用。我必须在全局范围内重新安装create react应用程序

    我解决此问题的步骤是:

  • npm卸载-g创建react应用程序
  • npm安装-g创建反应应用程序
  • npx创建反应应用程序我的应用程序
  • 这解决了我的问题

    步骤:

    1.卸载create react应用程序

    npm uninstall -g create-react-app
    
    2.现在只要使用

    npx create-react-app my-app
    

    这将自动为u创建模板。

    这是一个奇怪的问题,因为我昨天遇到了这个问题,今天早上遇到了相同的错误。根据发行说明,添加了一个新功能以支持模板,因此命令行中的一些部分似乎已更改(例如,
    --typescript
    被弃用,取而代之的是使用
    --template typescript

    我确实通过以下方式实现了这一切:

  • 卸载全局创建反应应用程序
    npm卸载创建反应应用程序-g
  • 验证npm缓存
    npm缓存验证
  • 关闭终端。我使用mac终端,如果使用IDE,可能会关闭并重新打开
  • 重新打开终端,浏览到您希望项目的位置,并使用新的模板命令约定通过npx运行create react app。为了使其正常工作,我使用了文档站点上的类型脚本my app以确保一致性:
    npx create react app my app--template typescript

  • 如果它正常工作,您将看到多个安装:一个用于react脚本,一个用于模板。错误消息也将不再出现。

    首先通过以下命令全局卸载create react app:

    yarn global upgrade create-react-app
    
    npm uninstall -g create-react-app
    
    npm uninstall -g create-react-app
    
    npm uninstall -g create-react-app
    
    然后在项目目录中:

    npm install create-react-app@latest
    
    npm install create-react-app@latest
    
    npm install create-react-app@latest
    
    最后:

    npx create-react-app my-app
    

    对于Linux,这对我来说很有用

    sudo npm uninstall -g create-react-app
    npx create-react-app my-test-app
    
    1)

    2)

    似乎存在一个错误,create react app未正确卸载,使用其中一个新命令会导致:

    未提供模板。这可能是因为您正在使用 create react应用程序的过期版本

    使用
    npm uninstall-g create react app
    卸载后,请检查您是否仍在命令行上使用
    which create react app
    (Windows:
    where create react app
    )将其“安装”。如果它返回某些内容(例如/usr/local/bin/create react app),然后执行
    rm-rf/usr/local/bin/create-react-app
    手动删除

    3)

    那么其中一种方法是:

    npx create-react-app my-app
    npm init react-app my-app
    yarn create react-app my-app
    
    这对我有用

    1)
    npm卸载-g创建反应应用程序

    2)
    npm安装-g创建react应用程序

    3)
    npx创建react应用程序名称

    如果您以前通过
    npm install-g create react app
    全局安装了任何
    create react app
    ,最好使用
    npm uninstall-g create react app


    这两个步骤对我很有效

    sudo npm uninstall -g create-react-app
    npx create-react-app my-test-app
    
    1) 使用此命令全局卸载react应用程序

    npm uninstall -g create-react-app
    
    npx create-react-app project-name
    
    2) 使用此命令在项目文件夹中安装了react应用程序

    npm uninstall -g create-react-app
    
    npx create-react-app project-name
    

    在MacOS上,所有选项都不适用于我。适用的是以下3个步骤:

  • 从以下位置删除节点:/usr/local/bin/
  • 然后

  • 新安装节点:
  • 然后

  • 安装react:npx创建react应用程序我的应用程序如下:

  • 首先清除npm缓存,然后按如下方式使用纱线:

    • npm缓存清理--强制执行npm install create-react-app@latest
      
      npx create-react-app my-app
      
      npx create-react-app my-app --template typescript
      
      npx --ignore-existing create-react-app [project name]