一行命令搞定 Cloudflare Pages 自动创建 + 部署

一行命令搞定 Cloudflare Pages 自动创建 + 部署

macOS / Linux

npx wrangler pages project create <name> --production-branch main 2>/dev/null; CLOUDFLARE_API_TOKEN="xxx" npx wrangler pages deploy ./dist --project-name "<name>"

Windows PowerShell

npx wrangler pages project create <name> --production-branch main 2>$null; $env:CLOUDFLARE_API_TOKEN="xxx"; npx wrangler pages deploy ./dist --project-name "<name>"

Windows CMD

npx wrangler pages project create <name> --production-branch main 2>nul && set CLOUDFLARE_API_TOKEN=xxx && npx wrangler pages deploy ./dist --project-name "<name>"

注意:CMD 中 2>nul 会吞掉所有错误,包括真正的异常。推荐用 PowerShell 或 Git Bash。


差异速查

平台 静默错误 设置环境变量 串联命令
macOS / Linux 2>/dev/null 行内直接写 ;
PowerShell 2>$null $env:VAR="val" ;
CMD 2>nul set VAR=val &&

使用前替换

  • <name> → 你的项目名

  • xxx → 你的 Cloudflare API Token

  • ./dist → 你的构建产物目录(如 ./build./out

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容