Appearance
Create-hono
create-hono 支持的命令行选项——当你运行 npm create hono@latest、npx create-hono@latest 或 pnpm 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.
NOTE
为什么是这一页? 安装 / 快速入门示例通常显示一个最小的 npm create hono@latest my-app 命令。create-hono 支持几个有用的标志,你可以传递这些标志来自动化和自定义项目创建(选择模板、跳过提示、选择包管理器、使用本地缓存等)。
传递参数:
🌐 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-workerssh
# "--template cloudflare-workers" selects the Cloudflare Workers template
yarn create hono my-app --template cloudflare-workerssh
# "--template cloudflare-workers" selects the Cloudflare Workers template
pnpm create hono@latest my-app --template cloudflare-workerssh
# "--template cloudflare-workers" selects the Cloudflare Workers template
bun create hono@latest my-app --template cloudflare-workerssh
# "--template cloudflare-workers" selects the Cloudflare Workers template
deno init --npm hono@latest my-app --template cloudflare-workers常用参数
🌐 Commonly used arguments
| 参数 | 描述 | 示例 |
|---|---|---|
--template <template> | 选择一个起始模板并跳过交互式模板提示。模板可能包括诸如 bun、cloudflare-workers、vercel 等名称。 | --template cloudflare-workers |
--install | 在模板创建后自动安装依赖。 | --install |
--pm <packageManager> | 指定安装依赖时使用的包管理器。常见值:npm、pnpm、yarn。 | --pm pnpm |
--offline | 使用本地缓存/模板,而不是获取最新的远程模板。适用于离线环境或确定性的本地运行。 | --offline |
NOTE
精确的模板集合和可用选项由 create-hono 项目维护。此文档页面总结了最常用的标志 —— 有关完整、权威的参考,请参见下面链接的仓库。
示例流程
🌐 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时通过--转发它。 - 要查看最新的模板和标志列表,请查阅
create-hono仓库,或在本地运行初始化程序并按照其帮助输出操作。
链接和参考
🌐 Links & references
create-hono仓库 : create-hono