[{"data":1,"prerenderedAt":848},["ShallowReactive",2],{"blog-blog_1":3,"blog-list":489},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"body":16,"_type":483,"_id":484,"_source":485,"_file":486,"_stem":487,"_extension":488},"\u002Fblog\u002Fblog_1","blog",false,"","Nuxt3 项目适配 Cloudflare Pages 跨平台部署全记录","从 Windows 本地开发到 Cloudflare Pages（Linux 云端）自动构建的完整踩坑与解决方案，包括跨平台二进制冲突、缓存不同步、域名重定向等实战经验","2026-07-13",[12,13,14,15],"Nuxt3","Cloudflare","部署","踩坑记录",{"type":17,"children":18,"toc":461},"root",[19,27,32,36,43,48,59,62,68,75,89,95,100,135,141,169,174,180,204,217,223,244,250,255,258,264,270,289,297,302,308,313,391,397,402,405,411,417,422,428,447,452,455],{"type":20,"tag":21,"props":22,"children":23},"element","p",{},[24],{"type":25,"value":26},"text","个人网站域名（在 Space 买的，转入 Cloudflare 管理）搭配 GitHub + Cloudflare Pages 实现自动化部署——本地修改代码，push 到 GitHub，Cloudflare 自动拉取构建上线。。",{"type":20,"tag":21,"props":28,"children":29},{},[30],{"type":25,"value":31},"这篇文章完整记录了从 Windows 本地开发环境到 Cloudflare Pages（Linux 构建环境）的适配全过程",{"type":20,"tag":33,"props":34,"children":35},"hr",{},[],{"type":20,"tag":37,"props":38,"children":40},"h2",{"id":39},"一冲突根源",[41],{"type":25,"value":42},"一、冲突根源",{"type":20,"tag":21,"props":44,"children":45},{},[46],{"type":25,"value":47},"本地 Windows 系统下载的依赖二进制包（oxc、esbuild 等）是 Windows 平台专属，而 Cloudflare Pages 云端构建服务器为 Linux 系统。直接推送代码会出现跨平台二进制文件报错，构建失败。",{"type":20,"tag":21,"props":49,"children":50},{},[51,53],{"type":25,"value":52},"说白了：",{"type":20,"tag":54,"props":55,"children":56},"strong",{},[57],{"type":25,"value":58},"Windows 装的依赖，Linux 不认。",{"type":20,"tag":33,"props":60,"children":61},{},[],{"type":20,"tag":37,"props":63,"children":65},{"id":64},"二本地-windows-端清理适配步骤",[66],{"type":25,"value":67},"二、本地 Windows 端清理适配步骤",{"type":20,"tag":69,"props":70,"children":72},"h3",{"id":71},"_1-停止本地开发服务",[73],{"type":25,"value":74},"1. 停止本地开发服务",{"type":20,"tag":21,"props":76,"children":77},{},[78,80,87],{"type":25,"value":79},"关闭 ",{"type":20,"tag":81,"props":82,"children":84},"code",{"className":83},[],[85],{"type":25,"value":86},"npm run dev",{"type":25,"value":88}," 运行中的项目，避免文件占用。",{"type":20,"tag":69,"props":90,"children":92},{"id":91},"_2-清除平台锁定依赖",[93],{"type":25,"value":94},"2. 清除平台锁定依赖",{"type":20,"tag":21,"props":96,"children":97},{},[98],{"type":25,"value":99},"删除项目根目录两处文件：",{"type":20,"tag":101,"props":102,"children":103},"ul",{},[104,116],{"type":20,"tag":105,"props":106,"children":107},"li",{},[108,114],{"type":20,"tag":81,"props":109,"children":111},{"className":110},[],[112],{"type":25,"value":113},"node_modules",{"type":25,"value":115}," 完整文件夹",{"type":20,"tag":105,"props":117,"children":118},{},[119,121,127,129],{"type":25,"value":120},"锁文件 ",{"type":20,"tag":81,"props":122,"children":124},{"className":123},[],[125],{"type":25,"value":126},"package-lock.json",{"type":25,"value":128}," \u002F ",{"type":20,"tag":81,"props":130,"children":132},{"className":131},[],[133],{"type":25,"value":134},"yarn.lock",{"type":20,"tag":69,"props":136,"children":138},{"id":137},"_3-重装跨平台通用依赖",[139],{"type":25,"value":140},"3. 重装跨平台通用依赖",{"type":20,"tag":142,"props":143,"children":147},"pre",{"code":144,"language":145,"meta":7,"className":146,"style":7},"npm install\n","bash","language-bash shiki shiki-themes github-light github-dark",[148],{"type":20,"tag":81,"props":149,"children":150},{"__ignoreMap":7},[151],{"type":20,"tag":152,"props":153,"children":156},"span",{"class":154,"line":155},"line",1,[157,163],{"type":20,"tag":152,"props":158,"children":160},{"style":159},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[161],{"type":25,"value":162},"npm",{"type":20,"tag":152,"props":164,"children":166},{"style":165},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[167],{"type":25,"value":168}," install\n",{"type":20,"tag":21,"props":170,"children":171},{},[172],{"type":25,"value":173},"重新生成适配 Linux 的 lock 文件，这次不会再绑定 Windows 专属二进制程序。",{"type":20,"tag":69,"props":175,"children":177},{"id":176},"_4-本地验证打包",[178],{"type":25,"value":179},"4. 本地验证打包",{"type":20,"tag":142,"props":181,"children":183},{"code":182,"language":145,"meta":7,"className":146,"style":7},"npm run generate\n",[184],{"type":20,"tag":81,"props":185,"children":186},{"__ignoreMap":7},[187],{"type":20,"tag":152,"props":188,"children":189},{"class":154,"line":155},[190,194,199],{"type":20,"tag":152,"props":191,"children":192},{"style":159},[193],{"type":25,"value":162},{"type":20,"tag":152,"props":195,"children":196},{"style":165},[197],{"type":25,"value":198}," run",{"type":20,"tag":152,"props":200,"children":201},{"style":165},[202],{"type":25,"value":203}," generate\n",{"type":20,"tag":21,"props":205,"children":206},{},[207,209,215],{"type":25,"value":208},"根目录正常生成 ",{"type":20,"tag":81,"props":210,"children":212},{"className":211},[],[213],{"type":25,"value":214},"dist",{"type":25,"value":216}," 文件夹，代表打包逻辑无问题。",{"type":20,"tag":69,"props":218,"children":220},{"id":219},"_5-git-过滤依赖",[221],{"type":25,"value":222},"5. Git 过滤依赖",{"type":20,"tag":21,"props":224,"children":225},{},[226,228,234,236,242],{"type":25,"value":227},"确认 ",{"type":20,"tag":81,"props":229,"children":231},{"className":230},[],[232],{"type":25,"value":233},".gitignore",{"type":25,"value":235}," 文件包含 ",{"type":20,"tag":81,"props":237,"children":239},{"className":238},[],[240],{"type":25,"value":241},"node_modules\u002F",{"type":25,"value":243},"，禁止上传超大依赖文件夹至仓库。",{"type":20,"tag":69,"props":245,"children":247},{"id":246},"_6-推送代码",[248],{"type":25,"value":249},"6. 推送代码",{"type":20,"tag":21,"props":251,"children":252},{},[253],{"type":25,"value":254},"将修改后的源码提交、push 到 Gitee\u002FGitHub 远程仓库。",{"type":20,"tag":33,"props":256,"children":257},{},[],{"type":20,"tag":37,"props":259,"children":261},{"id":260},"三cloudflare-pages-云端-linux-环境配置",[262],{"type":25,"value":263},"三、Cloudflare Pages 云端 Linux 环境配置",{"type":20,"tag":69,"props":265,"children":267},{"id":266},"_1-添加环境变量解决跨平台编译",[268],{"type":25,"value":269},"1. 添加环境变量解决跨平台编译",{"type":20,"tag":21,"props":271,"children":272},{},[273,275,280,282,287],{"type":25,"value":274},"进入 Pages 项目面板 → ",{"type":20,"tag":54,"props":276,"children":277},{},[278],{"type":25,"value":279},"设置",{"type":25,"value":281}," → ",{"type":20,"tag":54,"props":283,"children":284},{},[285],{"type":25,"value":286},"环境变量",{"type":25,"value":288},"，新增变量：",{"type":20,"tag":142,"props":290,"children":292},{"code":291},"变量名：NODE_ENV                   值：production\n变量名：NODE_VERSION               值：20\n变量名：NPM_CONFIG_CI              值：false\n变量名：npm_config_oxc_platform    值：linux\n\n\n",[293],{"type":20,"tag":81,"props":294,"children":295},{"__ignoreMap":7},[296],{"type":25,"value":291},{"type":20,"tag":21,"props":298,"children":299},{},[300],{"type":25,"value":301},"强制云端使用 Linux 版本编译工具，这是解决 oxc 等二进制包跨平台报错的关键。",{"type":20,"tag":69,"props":303,"children":305},{"id":304},"_2-核对构建命令",[306],{"type":25,"value":307},"2. 核对构建命令",{"type":20,"tag":21,"props":309,"children":310},{},[311],{"type":25,"value":312},"Nuxt SSG 静态打包固定构建指令：",{"type":20,"tag":314,"props":315,"children":316},"table",{},[317,336],{"type":20,"tag":318,"props":319,"children":320},"thead",{},[321],{"type":20,"tag":322,"props":323,"children":324},"tr",{},[325,331],{"type":20,"tag":326,"props":327,"children":328},"th",{},[329],{"type":25,"value":330},"配置项",{"type":20,"tag":326,"props":332,"children":333},{},[334],{"type":25,"value":335},"值",{"type":20,"tag":337,"props":338,"children":339},"tbody",{},[340,358,375],{"type":20,"tag":322,"props":341,"children":342},{},[343,349],{"type":20,"tag":344,"props":345,"children":346},"td",{},[347],{"type":25,"value":348},"安装命令",{"type":20,"tag":344,"props":350,"children":351},{},[352],{"type":20,"tag":81,"props":353,"children":355},{"className":354},[],[356],{"type":25,"value":357},"npm install",{"type":20,"tag":322,"props":359,"children":360},{},[361,366],{"type":20,"tag":344,"props":362,"children":363},{},[364],{"type":25,"value":365},"构建命令",{"type":20,"tag":344,"props":367,"children":368},{},[369],{"type":20,"tag":81,"props":370,"children":372},{"className":371},[],[373],{"type":25,"value":374},"npm run generate",{"type":20,"tag":322,"props":376,"children":377},{},[378,383],{"type":20,"tag":344,"props":379,"children":380},{},[381],{"type":25,"value":382},"输出目录",{"type":20,"tag":344,"props":384,"children":385},{},[386],{"type":20,"tag":81,"props":387,"children":389},{"className":388},[],[390],{"type":25,"value":214},{"type":20,"tag":69,"props":392,"children":394},{"id":393},"_3-清理旧失败部署记录",[395],{"type":25,"value":396},"3. 清理旧失败部署记录",{"type":20,"tag":21,"props":398,"children":399},{},[400],{"type":25,"value":401},"删除历史构建记录，触发全新完整构建，避免旧缓存干扰。",{"type":20,"tag":33,"props":403,"children":404},{},[],{"type":20,"tag":37,"props":406,"children":408},{"id":407},"四两种部署方案对比",[409],{"type":25,"value":410},"四、两种部署方案对比",{"type":20,"tag":69,"props":412,"children":414},{"id":413},"方案一git-自动构建推荐",[415],{"type":25,"value":416},"方案一：Git 自动构建（推荐）",{"type":20,"tag":21,"props":418,"children":419},{},[420],{"type":25,"value":421},"完成本地清理 + 云端环境变量配置后，每次 Windows 本地改代码 push 仓库，Linux 云端自动重新打包、部署。",{"type":20,"tag":69,"props":423,"children":425},{"id":424},"方案二手动拖放-dist-文件夹",[426],{"type":25,"value":427},"方案二：手动拖放 dist 文件夹",{"type":20,"tag":21,"props":429,"children":430},{},[431,433,438,440,445],{"type":25,"value":432},"若自动构建持续报错，本地 Windows 执行 ",{"type":20,"tag":81,"props":434,"children":436},{"className":435},[],[437],{"type":25,"value":374},{"type":25,"value":439}," 生成 ",{"type":20,"tag":81,"props":441,"children":443},{"className":442},[],[444],{"type":25,"value":214},{"type":25,"value":446},"，直接手动上传至 Cloudflare Pages，绕过 Linux 云端构建步骤。",{"type":20,"tag":21,"props":448,"children":449},{},[450],{"type":25,"value":451},"优点是无跨平台冲突，缺点是每次修改需要手动上传文件。",{"type":20,"tag":33,"props":453,"children":454},{},[],{"type":20,"tag":456,"props":457,"children":458},"style",{},[459],{"type":25,"value":460},"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":7,"searchDepth":462,"depth":462,"links":463},2,[464,465,474,479],{"id":39,"depth":462,"text":42},{"id":64,"depth":462,"text":67,"children":466},[467,469,470,471,472,473],{"id":71,"depth":468,"text":74},3,{"id":91,"depth":468,"text":94},{"id":137,"depth":468,"text":140},{"id":176,"depth":468,"text":179},{"id":219,"depth":468,"text":222},{"id":246,"depth":468,"text":249},{"id":260,"depth":462,"text":263,"children":475},[476,477,478],{"id":266,"depth":468,"text":269},{"id":304,"depth":468,"text":307},{"id":393,"depth":468,"text":396},{"id":407,"depth":462,"text":410,"children":480},[481,482],{"id":413,"depth":468,"text":416},{"id":424,"depth":468,"text":427},"markdown","content:blog:blog_1.md","content","blog\u002Fblog_1.md","blog\u002Fblog_1","md",[490],{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":491,"body":492,"_type":483,"_id":484,"_source":485,"_file":486,"_stem":487,"_extension":488},[12,13,14,15],{"type":17,"children":493,"toc":828},[494,498,502,505,509,513,521,524,528,532,542,546,550,577,581,598,602,606,627,637,641,657,661,665,668,672,676,690,697,701,705,709,774,778,782,785,789,793,797,801,817,821,824],{"type":20,"tag":21,"props":495,"children":496},{},[497],{"type":25,"value":26},{"type":20,"tag":21,"props":499,"children":500},{},[501],{"type":25,"value":31},{"type":20,"tag":33,"props":503,"children":504},{},[],{"type":20,"tag":37,"props":506,"children":507},{"id":39},[508],{"type":25,"value":42},{"type":20,"tag":21,"props":510,"children":511},{},[512],{"type":25,"value":47},{"type":20,"tag":21,"props":514,"children":515},{},[516,517],{"type":25,"value":52},{"type":20,"tag":54,"props":518,"children":519},{},[520],{"type":25,"value":58},{"type":20,"tag":33,"props":522,"children":523},{},[],{"type":20,"tag":37,"props":525,"children":526},{"id":64},[527],{"type":25,"value":67},{"type":20,"tag":69,"props":529,"children":530},{"id":71},[531],{"type":25,"value":74},{"type":20,"tag":21,"props":533,"children":534},{},[535,536,541],{"type":25,"value":79},{"type":20,"tag":81,"props":537,"children":539},{"className":538},[],[540],{"type":25,"value":86},{"type":25,"value":88},{"type":20,"tag":69,"props":543,"children":544},{"id":91},[545],{"type":25,"value":94},{"type":20,"tag":21,"props":547,"children":548},{},[549],{"type":25,"value":99},{"type":20,"tag":101,"props":551,"children":552},{},[553,562],{"type":20,"tag":105,"props":554,"children":555},{},[556,561],{"type":20,"tag":81,"props":557,"children":559},{"className":558},[],[560],{"type":25,"value":113},{"type":25,"value":115},{"type":20,"tag":105,"props":563,"children":564},{},[565,566,571,572],{"type":25,"value":120},{"type":20,"tag":81,"props":567,"children":569},{"className":568},[],[570],{"type":25,"value":126},{"type":25,"value":128},{"type":20,"tag":81,"props":573,"children":575},{"className":574},[],[576],{"type":25,"value":134},{"type":20,"tag":69,"props":578,"children":579},{"id":137},[580],{"type":25,"value":140},{"type":20,"tag":142,"props":582,"children":583},{"code":144,"language":145,"meta":7,"className":146,"style":7},[584],{"type":20,"tag":81,"props":585,"children":586},{"__ignoreMap":7},[587],{"type":20,"tag":152,"props":588,"children":589},{"class":154,"line":155},[590,594],{"type":20,"tag":152,"props":591,"children":592},{"style":159},[593],{"type":25,"value":162},{"type":20,"tag":152,"props":595,"children":596},{"style":165},[597],{"type":25,"value":168},{"type":20,"tag":21,"props":599,"children":600},{},[601],{"type":25,"value":173},{"type":20,"tag":69,"props":603,"children":604},{"id":176},[605],{"type":25,"value":179},{"type":20,"tag":142,"props":607,"children":608},{"code":182,"language":145,"meta":7,"className":146,"style":7},[609],{"type":20,"tag":81,"props":610,"children":611},{"__ignoreMap":7},[612],{"type":20,"tag":152,"props":613,"children":614},{"class":154,"line":155},[615,619,623],{"type":20,"tag":152,"props":616,"children":617},{"style":159},[618],{"type":25,"value":162},{"type":20,"tag":152,"props":620,"children":621},{"style":165},[622],{"type":25,"value":198},{"type":20,"tag":152,"props":624,"children":625},{"style":165},[626],{"type":25,"value":203},{"type":20,"tag":21,"props":628,"children":629},{},[630,631,636],{"type":25,"value":208},{"type":20,"tag":81,"props":632,"children":634},{"className":633},[],[635],{"type":25,"value":214},{"type":25,"value":216},{"type":20,"tag":69,"props":638,"children":639},{"id":219},[640],{"type":25,"value":222},{"type":20,"tag":21,"props":642,"children":643},{},[644,645,650,651,656],{"type":25,"value":227},{"type":20,"tag":81,"props":646,"children":648},{"className":647},[],[649],{"type":25,"value":233},{"type":25,"value":235},{"type":20,"tag":81,"props":652,"children":654},{"className":653},[],[655],{"type":25,"value":241},{"type":25,"value":243},{"type":20,"tag":69,"props":658,"children":659},{"id":246},[660],{"type":25,"value":249},{"type":20,"tag":21,"props":662,"children":663},{},[664],{"type":25,"value":254},{"type":20,"tag":33,"props":666,"children":667},{},[],{"type":20,"tag":37,"props":669,"children":670},{"id":260},[671],{"type":25,"value":263},{"type":20,"tag":69,"props":673,"children":674},{"id":266},[675],{"type":25,"value":269},{"type":20,"tag":21,"props":677,"children":678},{},[679,680,684,685,689],{"type":25,"value":274},{"type":20,"tag":54,"props":681,"children":682},{},[683],{"type":25,"value":279},{"type":25,"value":281},{"type":20,"tag":54,"props":686,"children":687},{},[688],{"type":25,"value":286},{"type":25,"value":288},{"type":20,"tag":142,"props":691,"children":692},{"code":291},[693],{"type":20,"tag":81,"props":694,"children":695},{"__ignoreMap":7},[696],{"type":25,"value":291},{"type":20,"tag":21,"props":698,"children":699},{},[700],{"type":25,"value":301},{"type":20,"tag":69,"props":702,"children":703},{"id":304},[704],{"type":25,"value":307},{"type":20,"tag":21,"props":706,"children":707},{},[708],{"type":25,"value":312},{"type":20,"tag":314,"props":710,"children":711},{},[712,726],{"type":20,"tag":318,"props":713,"children":714},{},[715],{"type":20,"tag":322,"props":716,"children":717},{},[718,722],{"type":20,"tag":326,"props":719,"children":720},{},[721],{"type":25,"value":330},{"type":20,"tag":326,"props":723,"children":724},{},[725],{"type":25,"value":335},{"type":20,"tag":337,"props":727,"children":728},{},[729,744,759],{"type":20,"tag":322,"props":730,"children":731},{},[732,736],{"type":20,"tag":344,"props":733,"children":734},{},[735],{"type":25,"value":348},{"type":20,"tag":344,"props":737,"children":738},{},[739],{"type":20,"tag":81,"props":740,"children":742},{"className":741},[],[743],{"type":25,"value":357},{"type":20,"tag":322,"props":745,"children":746},{},[747,751],{"type":20,"tag":344,"props":748,"children":749},{},[750],{"type":25,"value":365},{"type":20,"tag":344,"props":752,"children":753},{},[754],{"type":20,"tag":81,"props":755,"children":757},{"className":756},[],[758],{"type":25,"value":374},{"type":20,"tag":322,"props":760,"children":761},{},[762,766],{"type":20,"tag":344,"props":763,"children":764},{},[765],{"type":25,"value":382},{"type":20,"tag":344,"props":767,"children":768},{},[769],{"type":20,"tag":81,"props":770,"children":772},{"className":771},[],[773],{"type":25,"value":214},{"type":20,"tag":69,"props":775,"children":776},{"id":393},[777],{"type":25,"value":396},{"type":20,"tag":21,"props":779,"children":780},{},[781],{"type":25,"value":401},{"type":20,"tag":33,"props":783,"children":784},{},[],{"type":20,"tag":37,"props":786,"children":787},{"id":407},[788],{"type":25,"value":410},{"type":20,"tag":69,"props":790,"children":791},{"id":413},[792],{"type":25,"value":416},{"type":20,"tag":21,"props":794,"children":795},{},[796],{"type":25,"value":421},{"type":20,"tag":69,"props":798,"children":799},{"id":424},[800],{"type":25,"value":427},{"type":20,"tag":21,"props":802,"children":803},{},[804,805,810,811,816],{"type":25,"value":432},{"type":20,"tag":81,"props":806,"children":808},{"className":807},[],[809],{"type":25,"value":374},{"type":25,"value":439},{"type":20,"tag":81,"props":812,"children":814},{"className":813},[],[815],{"type":25,"value":214},{"type":25,"value":446},{"type":20,"tag":21,"props":818,"children":819},{},[820],{"type":25,"value":451},{"type":20,"tag":33,"props":822,"children":823},{},[],{"type":20,"tag":456,"props":825,"children":826},{},[827],{"type":25,"value":460},{"title":7,"searchDepth":462,"depth":462,"links":829},[830,831,839,844],{"id":39,"depth":462,"text":42},{"id":64,"depth":462,"text":67,"children":832},[833,834,835,836,837,838],{"id":71,"depth":468,"text":74},{"id":91,"depth":468,"text":94},{"id":137,"depth":468,"text":140},{"id":176,"depth":468,"text":179},{"id":219,"depth":468,"text":222},{"id":246,"depth":468,"text":249},{"id":260,"depth":462,"text":263,"children":840},[841,842,843],{"id":266,"depth":468,"text":269},{"id":304,"depth":468,"text":307},{"id":393,"depth":468,"text":396},{"id":407,"depth":462,"text":410,"children":845},[846,847],{"id":413,"depth":468,"text":416},{"id":424,"depth":468,"text":427},1784084822893]