Skip to content

Create-hono

create-hono 支持的命令行选项 - 运行 npm create hono@latestnpx create-hono@latestpnpm create hono@latest 时运行的项目初始化程序。

¥Command-line options supported by create-hono - the project initializer that runs when you run npm create hono@latest, npx create-hono@latest, or pnpm create hono@latest.

为什么是此页面?安装/快速入门示例通常显示最简的 `npm create hono@latest my-app` 命令。`create-hono` 支持多个有用的标志,你可以传递这些标志来自动化和自定义项目创建(选择模板、跳过提示、选择包管理器、使用本地缓存等等)。

¥[!NOTE] Why this page? The installation / quick-start examples often show a minimal npm create hono@latest my-app command. create-hono supports several useful flags you can pass to automate and customize project creation (select templates, skip prompts, pick a package manager, use local cache, and more).

传递参数:

¥Passing arguments:

使用 npm create(或 npx)时,用于初始化脚本的参数必须放在 -- 之后。-- 之后的任何内容都会转发到初始化程序。

¥When you use npm create (or npx) arguments intended for the initializer script must be placed after --. Anything after -- is forwarded to the initializer.

sh
# Forwarding arguments to create-hono (npm requires `--`)
npm create hono@latest my-app -- --template cloudflare-workers
sh
# "--template cloudflare-workers" selects the Cloudflare Workers template
yarn create hono my-app --template cloudflare-workers
sh
# "--template cloudflare-workers" selects the Cloudflare Workers template
pnpm create hono@latest my-app --template cloudflare-workers
sh
# "--template cloudflare-workers" selects the Cloudflare Workers template
bun create hono@latest my-app --template cloudflare-workers
sh
# "--template cloudflare-workers" selects the Cloudflare Workers template
deno init --npm hono@latest my-app --template cloudflare-workers

常用参数

¥Commonly used arguments

参数描述示例
--template <template>选择一个入门模板并跳过交互式模板提示。模板可以包含 buncloudflare-workersvercel 等名称。--template cloudflare-workers
--install模板创建后自动安装依赖。--install
--pm <packageManager>指定安装依赖时要运行的包管理器。常用值:npm, pnpm, yarn.--pm pnpm
--offline使用本地缓存/模板,而不是获取最新的远程模板。适用于离线环境或确定性本地运行。--offline

确切的模板和可用选项集由 `create-hono` 项目维护。此文档页面总结了最常用的标志 - 请参阅下面链接的存储库以获取完整、权威的参考。

¥[!NOTE] The exact set of templates and available options is maintained by the create-hono project. This docs page summarizes the most-used flags — see the linked repository below for the full, authoritative reference.

示例流程

¥Example flows

最小,交互式

¥Minimal, interactive

bash
npm create hono@latest my-app

这会提示你输入模板和选项。

¥This prompts you for template and options.

非交互式,选择模板和包管理器

¥Non-interactive, pick template and package manager

bash
npm create hono@latest my-app -- --template vercel --pm npm --install

这将使用 vercel 模板创建 my-app,使用 npm 安装依赖,并跳过交互式提示。

¥This creates my-app using the vercel template, installs dependencies using npm, and skips the interactive prompts.

使用离线缓存(无网络)

¥Use offline cache (no network)

bash
pnpm create hono@latest my-app --template deno --offline

故障排除和提示

¥Troubleshooting & tips

  • 如果某个选项似乎无法识别,请确保在使用 npm create/npx 时使用 -- 转发该选项。

    ¥If an option appears not to be recognized, make sure you're forwarding it with -- when using npm create / npx .

  • 要查看最新的模板和标志列表,请查阅 create-hono 存储库或在本地运行初始化程序并遵循其帮助输出。

    ¥To see the most current list of templates and flags, consult the create-hono repository or run the initializer locally and follow its help output.

链接和参考

¥Links & references

Hono v4.10 中文网 - 粤ICP备13048890号