当前位置: 首页 > 面试题库 >

未使用create-react-app提供模板

霍财
2023-03-14
问题内容

当我create-react-app my-app在终端中键入命令时,它似乎可以正常工作-
成功下载所有库等。但是,在该过程结束时,我收到一条消息,提示您template was not provided

输入项

user@users-MacBook-Pro-2 Desktop% 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中my-app

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

我检查了CRA 更改日志,看起来好像增加了对自定义模板的支持-但是看起来命令create-react-app my- app似乎没有更改。

知道这里发生了什么吗?


问题答案:

如果您以前create-react-app通过进行了全局安装npm install -g create-react-app,建议您使用npm uninstall -g create-react-app来卸载软件包,以确保npx始终使用最新版本。

文件

使用以下命令之一:

  • npx create-react-app my-app
  • npm init react-app my-app
  • yarn create react-app my-app

如果npm uninstall -g create-react-app上面说不起作用。 键入which create-react- app以了解其安装位置。我的被​​安装在/usr/bin文件夹中。然后做sudo rm -rf /usr/bin/create-react- app。(以下为@ v42的评论)



 类似资料:
  • 问题内容: 我正在尝试托管一个我使用Facebook样板在本地创建和测试的React应用。 客户端应用程序与我使用node.js制作的API进行了交互,并且使用该API可以毫无问题地建立安全连接(通过node.js客户端发送我的SSL证书进行测试)。 但是,在使用react发送我的SSL证书而不是自签名证书时,我遇到了困难,这导致我使用chrome并尝试访问https://example.net:

  • Create React App 不用配置就可以创建 React App。 全局安装: npm install -g create-react-app 创建 App: create-react-app my-appcd my-app/ 启动 npm: npm start 打开 http://localhost:3000/  查看你的 App。 如果你准备将其部署到生产环境,只需创建一个压缩包,并且运行 npm run build。

  • 创建响应应用时,图像中出现错误。它一直在正常工作,我所做的就是mkdir和cd到那个dir。 这就是错误的样子... NPX:在36.634s中安装了99必须使用导入来加载ES模块: C:\用户\Neeraj\AppData\漫游\npm-cache_npx\5172\node_modules\create-react-app\node_modules\is-promise\index.js不支持

  • 问题内容: 根据Dan Abramov 的推文,CSS模块支持位于create- react-app(CRA)中。只需扩展其样式表即可启用该功能,但这对我不起作用。我的版本为1.1.4 。如何使用CRA启用CSS模块?谢谢 问题答案: 您无需弹出。 从版本2开始,Create React App就立即支持CSS模块,该版本现已稳定。 通过运行或升级到v2()。 您只需要创建带有扩展名的文件 例如:

  • Create React Native App The fastest way to create universal React Native apps npx create-react-native-app Once you're up and running with Create React Native App, visit this tutorial for more informat

  • Create React Redux App Structure Create React + Redux app structure with build configurations. What can I find here? Express, Cors React + Redux, ES6, async/await Web Components (Custom Elements) inte