[{"data":1,"prerenderedAt":491},["ShallowReactive",2],{"blog-":3,"blog-list":4},null,[5],{"_path":6,"_dir":7,"_draft":8,"_partial":8,"_locale":9,"title":10,"description":11,"date":12,"tags":13,"body":18,"_type":485,"_id":486,"_source":487,"_file":488,"_stem":489,"_extension":490},"\u002Fblog\u002Fblog_1","blog",false,"","Nuxt3 项目适配 Cloudflare Pages 跨平台部署全记录","从 Windows 本地开发到 Cloudflare Pages（Linux 云端）自动构建的完整踩坑与解决方案，包括跨平台二进制冲突、缓存不同步、域名重定向等实战经验","2026-07-13",[14,15,16,17],"Nuxt3","Cloudflare","部署","踩坑记录",{"type":19,"children":20,"toc":463},"root",[21,29,34,38,45,50,61,64,70,77,91,97,102,137,143,171,176,182,206,219,225,246,252,257,260,266,272,291,299,304,310,315,393,399,404,407,413,419,424,430,449,454,457],{"type":22,"tag":23,"props":24,"children":25},"element","p",{},[26],{"type":27,"value":28},"text","个人网站域名（在 Space 买的，转入 Cloudflare 管理）搭配 GitHub + Cloudflare Pages 实现自动化部署——本地修改代码，push 到 GitHub，Cloudflare 自动拉取构建上线。。",{"type":22,"tag":23,"props":30,"children":31},{},[32],{"type":27,"value":33},"这篇文章完整记录了从 Windows 本地开发环境到 Cloudflare Pages（Linux 构建环境）的适配全过程",{"type":22,"tag":35,"props":36,"children":37},"hr",{},[],{"type":22,"tag":39,"props":40,"children":42},"h2",{"id":41},"一冲突根源",[43],{"type":27,"value":44},"一、冲突根源",{"type":22,"tag":23,"props":46,"children":47},{},[48],{"type":27,"value":49},"本地 Windows 系统下载的依赖二进制包（oxc、esbuild 等）是 Windows 平台专属，而 Cloudflare Pages 云端构建服务器为 Linux 系统。直接推送代码会出现跨平台二进制文件报错，构建失败。",{"type":22,"tag":23,"props":51,"children":52},{},[53,55],{"type":27,"value":54},"说白了：",{"type":22,"tag":56,"props":57,"children":58},"strong",{},[59],{"type":27,"value":60},"Windows 装的依赖，Linux 不认。",{"type":22,"tag":35,"props":62,"children":63},{},[],{"type":22,"tag":39,"props":65,"children":67},{"id":66},"二本地-windows-端清理适配步骤",[68],{"type":27,"value":69},"二、本地 Windows 端清理适配步骤",{"type":22,"tag":71,"props":72,"children":74},"h3",{"id":73},"_1-停止本地开发服务",[75],{"type":27,"value":76},"1. 停止本地开发服务",{"type":22,"tag":23,"props":78,"children":79},{},[80,82,89],{"type":27,"value":81},"关闭 ",{"type":22,"tag":83,"props":84,"children":86},"code",{"className":85},[],[87],{"type":27,"value":88},"npm run dev",{"type":27,"value":90}," 运行中的项目，避免文件占用。",{"type":22,"tag":71,"props":92,"children":94},{"id":93},"_2-清除平台锁定依赖",[95],{"type":27,"value":96},"2. 清除平台锁定依赖",{"type":22,"tag":23,"props":98,"children":99},{},[100],{"type":27,"value":101},"删除项目根目录两处文件：",{"type":22,"tag":103,"props":104,"children":105},"ul",{},[106,118],{"type":22,"tag":107,"props":108,"children":109},"li",{},[110,116],{"type":22,"tag":83,"props":111,"children":113},{"className":112},[],[114],{"type":27,"value":115},"node_modules",{"type":27,"value":117}," 完整文件夹",{"type":22,"tag":107,"props":119,"children":120},{},[121,123,129,131],{"type":27,"value":122},"锁文件 ",{"type":22,"tag":83,"props":124,"children":126},{"className":125},[],[127],{"type":27,"value":128},"package-lock.json",{"type":27,"value":130}," \u002F ",{"type":22,"tag":83,"props":132,"children":134},{"className":133},[],[135],{"type":27,"value":136},"yarn.lock",{"type":22,"tag":71,"props":138,"children":140},{"id":139},"_3-重装跨平台通用依赖",[141],{"type":27,"value":142},"3. 重装跨平台通用依赖",{"type":22,"tag":144,"props":145,"children":149},"pre",{"code":146,"language":147,"meta":9,"className":148,"style":9},"npm install\n","bash","language-bash shiki shiki-themes github-light github-dark",[150],{"type":22,"tag":83,"props":151,"children":152},{"__ignoreMap":9},[153],{"type":22,"tag":154,"props":155,"children":158},"span",{"class":156,"line":157},"line",1,[159,165],{"type":22,"tag":154,"props":160,"children":162},{"style":161},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[163],{"type":27,"value":164},"npm",{"type":22,"tag":154,"props":166,"children":168},{"style":167},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[169],{"type":27,"value":170}," install\n",{"type":22,"tag":23,"props":172,"children":173},{},[174],{"type":27,"value":175},"重新生成适配 Linux 的 lock 文件，这次不会再绑定 Windows 专属二进制程序。",{"type":22,"tag":71,"props":177,"children":179},{"id":178},"_4-本地验证打包",[180],{"type":27,"value":181},"4. 本地验证打包",{"type":22,"tag":144,"props":183,"children":185},{"code":184,"language":147,"meta":9,"className":148,"style":9},"npm run generate\n",[186],{"type":22,"tag":83,"props":187,"children":188},{"__ignoreMap":9},[189],{"type":22,"tag":154,"props":190,"children":191},{"class":156,"line":157},[192,196,201],{"type":22,"tag":154,"props":193,"children":194},{"style":161},[195],{"type":27,"value":164},{"type":22,"tag":154,"props":197,"children":198},{"style":167},[199],{"type":27,"value":200}," run",{"type":22,"tag":154,"props":202,"children":203},{"style":167},[204],{"type":27,"value":205}," generate\n",{"type":22,"tag":23,"props":207,"children":208},{},[209,211,217],{"type":27,"value":210},"根目录正常生成 ",{"type":22,"tag":83,"props":212,"children":214},{"className":213},[],[215],{"type":27,"value":216},"dist",{"type":27,"value":218}," 文件夹，代表打包逻辑无问题。",{"type":22,"tag":71,"props":220,"children":222},{"id":221},"_5-git-过滤依赖",[223],{"type":27,"value":224},"5. Git 过滤依赖",{"type":22,"tag":23,"props":226,"children":227},{},[228,230,236,238,244],{"type":27,"value":229},"确认 ",{"type":22,"tag":83,"props":231,"children":233},{"className":232},[],[234],{"type":27,"value":235},".gitignore",{"type":27,"value":237}," 文件包含 ",{"type":22,"tag":83,"props":239,"children":241},{"className":240},[],[242],{"type":27,"value":243},"node_modules\u002F",{"type":27,"value":245},"，禁止上传超大依赖文件夹至仓库。",{"type":22,"tag":71,"props":247,"children":249},{"id":248},"_6-推送代码",[250],{"type":27,"value":251},"6. 推送代码",{"type":22,"tag":23,"props":253,"children":254},{},[255],{"type":27,"value":256},"将修改后的源码提交、push 到 Gitee\u002FGitHub 远程仓库。",{"type":22,"tag":35,"props":258,"children":259},{},[],{"type":22,"tag":39,"props":261,"children":263},{"id":262},"三cloudflare-pages-云端-linux-环境配置",[264],{"type":27,"value":265},"三、Cloudflare Pages 云端 Linux 环境配置",{"type":22,"tag":71,"props":267,"children":269},{"id":268},"_1-添加环境变量解决跨平台编译",[270],{"type":27,"value":271},"1. 添加环境变量解决跨平台编译",{"type":22,"tag":23,"props":273,"children":274},{},[275,277,282,284,289],{"type":27,"value":276},"进入 Pages 项目面板 → ",{"type":22,"tag":56,"props":278,"children":279},{},[280],{"type":27,"value":281},"设置",{"type":27,"value":283}," → ",{"type":22,"tag":56,"props":285,"children":286},{},[287],{"type":27,"value":288},"环境变量",{"type":27,"value":290},"，新增变量：",{"type":22,"tag":144,"props":292,"children":294},{"code":293},"变量名：NODE_ENV                   值：production\n变量名：NODE_VERSION               值：20\n变量名：NPM_CONFIG_CI              值：false\n变量名：npm_config_oxc_platform    值：linux\n\n\n",[295],{"type":22,"tag":83,"props":296,"children":297},{"__ignoreMap":9},[298],{"type":27,"value":293},{"type":22,"tag":23,"props":300,"children":301},{},[302],{"type":27,"value":303},"强制云端使用 Linux 版本编译工具，这是解决 oxc 等二进制包跨平台报错的关键。",{"type":22,"tag":71,"props":305,"children":307},{"id":306},"_2-核对构建命令",[308],{"type":27,"value":309},"2. 核对构建命令",{"type":22,"tag":23,"props":311,"children":312},{},[313],{"type":27,"value":314},"Nuxt SSG 静态打包固定构建指令：",{"type":22,"tag":316,"props":317,"children":318},"table",{},[319,338],{"type":22,"tag":320,"props":321,"children":322},"thead",{},[323],{"type":22,"tag":324,"props":325,"children":326},"tr",{},[327,333],{"type":22,"tag":328,"props":329,"children":330},"th",{},[331],{"type":27,"value":332},"配置项",{"type":22,"tag":328,"props":334,"children":335},{},[336],{"type":27,"value":337},"值",{"type":22,"tag":339,"props":340,"children":341},"tbody",{},[342,360,377],{"type":22,"tag":324,"props":343,"children":344},{},[345,351],{"type":22,"tag":346,"props":347,"children":348},"td",{},[349],{"type":27,"value":350},"安装命令",{"type":22,"tag":346,"props":352,"children":353},{},[354],{"type":22,"tag":83,"props":355,"children":357},{"className":356},[],[358],{"type":27,"value":359},"npm install",{"type":22,"tag":324,"props":361,"children":362},{},[363,368],{"type":22,"tag":346,"props":364,"children":365},{},[366],{"type":27,"value":367},"构建命令",{"type":22,"tag":346,"props":369,"children":370},{},[371],{"type":22,"tag":83,"props":372,"children":374},{"className":373},[],[375],{"type":27,"value":376},"npm run generate",{"type":22,"tag":324,"props":378,"children":379},{},[380,385],{"type":22,"tag":346,"props":381,"children":382},{},[383],{"type":27,"value":384},"输出目录",{"type":22,"tag":346,"props":386,"children":387},{},[388],{"type":22,"tag":83,"props":389,"children":391},{"className":390},[],[392],{"type":27,"value":216},{"type":22,"tag":71,"props":394,"children":396},{"id":395},"_3-清理旧失败部署记录",[397],{"type":27,"value":398},"3. 清理旧失败部署记录",{"type":22,"tag":23,"props":400,"children":401},{},[402],{"type":27,"value":403},"删除历史构建记录，触发全新完整构建，避免旧缓存干扰。",{"type":22,"tag":35,"props":405,"children":406},{},[],{"type":22,"tag":39,"props":408,"children":410},{"id":409},"四两种部署方案对比",[411],{"type":27,"value":412},"四、两种部署方案对比",{"type":22,"tag":71,"props":414,"children":416},{"id":415},"方案一git-自动构建推荐",[417],{"type":27,"value":418},"方案一：Git 自动构建（推荐）",{"type":22,"tag":23,"props":420,"children":421},{},[422],{"type":27,"value":423},"完成本地清理 + 云端环境变量配置后，每次 Windows 本地改代码 push 仓库，Linux 云端自动重新打包、部署。",{"type":22,"tag":71,"props":425,"children":427},{"id":426},"方案二手动拖放-dist-文件夹",[428],{"type":27,"value":429},"方案二：手动拖放 dist 文件夹",{"type":22,"tag":23,"props":431,"children":432},{},[433,435,440,442,447],{"type":27,"value":434},"若自动构建持续报错，本地 Windows 执行 ",{"type":22,"tag":83,"props":436,"children":438},{"className":437},[],[439],{"type":27,"value":376},{"type":27,"value":441}," 生成 ",{"type":22,"tag":83,"props":443,"children":445},{"className":444},[],[446],{"type":27,"value":216},{"type":27,"value":448},"，直接手动上传至 Cloudflare Pages，绕过 Linux 云端构建步骤。",{"type":22,"tag":23,"props":450,"children":451},{},[452],{"type":27,"value":453},"优点是无跨平台冲突，缺点是每次修改需要手动上传文件。",{"type":22,"tag":35,"props":455,"children":456},{},[],{"type":22,"tag":458,"props":459,"children":460},"style",{},[461],{"type":27,"value":462},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":9,"searchDepth":464,"depth":464,"links":465},2,[466,467,476,481],{"id":41,"depth":464,"text":44},{"id":66,"depth":464,"text":69,"children":468},[469,471,472,473,474,475],{"id":73,"depth":470,"text":76},3,{"id":93,"depth":470,"text":96},{"id":139,"depth":470,"text":142},{"id":178,"depth":470,"text":181},{"id":221,"depth":470,"text":224},{"id":248,"depth":470,"text":251},{"id":262,"depth":464,"text":265,"children":477},[478,479,480],{"id":268,"depth":470,"text":271},{"id":306,"depth":470,"text":309},{"id":395,"depth":470,"text":398},{"id":409,"depth":464,"text":412,"children":482},[483,484],{"id":415,"depth":470,"text":418},{"id":426,"depth":470,"text":429},"markdown","content:blog:blog_1.md","content","blog\u002Fblog_1.md","blog\u002Fblog_1","md",1784084822889]