主分支
分支
主分支 (2.15.2)dev
版本
2.15.21.19.3v0.21.0
React Router v7 已发布。 查看文档
create-remix (CLI)

create-remix

刚开始使用 Remix 吗?最新版本的 Remix 现在是 React Router v7。 如果您想使用最新的框架功能,则应该使用 create-react-router CLI 来启动新项目

create-remix CLI 将创建一个新的 Remix 项目。如果不传递参数,此命令将启动一个交互式 CLI 来配置新项目并在给定目录中设置它。

npx create-remix@latest

或者,您可以将所需的目录路径作为参数传递

npx create-remix@latest <projectDir>

默认应用程序是使用内置 Remix App Server 的 TypeScript 应用程序。如果您希望基于不同的设置创建应用程序,则可以使用 --template 标志

npx create-remix@latest --template <templateUrl>

要获取可用命令和标志的完整列表,请运行

npx create-remix@latest --help

包管理器

create-remix 也可以使用各种包管理器调用,允许您在 npm、Yarn、pnpm 和 Bun 之间进行选择来管理安装过程。

npm create remix@latest <projectDir>
# or
yarn create remix@latest <projectDir>
# or
pnpm create remix@latest <projectDir>
# or
bunx create-remix@latest <projectDir>

create-remix --template

有关可用模板的更全面指南,请参阅我们的模板页面

一个有效的模板可以是

  • GitHub 仓库简写形式 — :username/:repo:username/:repo/:directory
  • GitHub 仓库的 URL(或其中的目录) — https://github.com/:username/:repohttps://github.com/:username/:repo/tree/:branch/:directory
    • 当使用此格式时,分支名称 (:branch) 不能包含 /,因为 create-remix 无法区分分支名称和目录路径
  • 远程 tarball 的 URL — https://example.com/remix-template.tar.gz
  • 指向文件目录的本地文件路径 — ./path/to/remix-template
  • 指向 tarball 的本地文件路径 — ./path/to/remix-template.tar.gz
npx create-remix@latest ./my-app --template remix-run/grunge-stack
npx create-remix@latest ./my-app --template remix-run/remix/templates/remix
npx create-remix@latest ./my-app --template remix-run/examples/basic
npx create-remix@latest ./my-app --template :username/:repo
npx create-remix@latest ./my-app --template :username/:repo/:directory
npx create-remix@latest ./my-app --template https://github.com/:username/:repo
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/tree/:branch
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/tree/:branch/:directory
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/archive/refs/tags/:tag.tar.gz
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/releases/latest/download/:tag.tar.gz
npx create-remix@latest ./my-app --template https://example.com/remix-template.tar.gz
npx create-remix@latest ./my-app --template ./path/to/remix-template
npx create-remix@latest ./my-app --template ./path/to/remix-template.tar.gz

create-remix --overwrite

如果 create-remix 检测到模板和您要在其中创建应用程序的目录之间存在任何文件冲突,它将提示您确认是否可以接受使用模板版本覆盖这些文件。您可以使用 --overwrite CLI 标志跳过此提示。

文档和示例根据以下许可 MIT