You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nuxt 3部署Firebase遇平台不兼容错误,求修复及指定版本部署方法

解决GitHub Actions部署Nuxt3到Firebase的平台兼容问题

问题概述

部署Nuxt3网站到Firebase时遇到平台兼容错误,具体信息如下:

注:使用ubuntu-22.04的20240225.1.0版本时部署曾正常运行。

错误日志:

Other logs here...
i  hosting: upload complete
✔  hosting[magpiethebrand]: file upload complete
i  functions: updating Node.js 18 (2nd Gen) function nuxt:server(europe-west3)...
Build failed with status: FAILURE and message: npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @css-inline/css-inline-linux-x64-musl@0.12.1: wanted {"os":"linux","cpu":"x64","libc":"musl"} (current: {"os":"linux","cpu":"x64","libc":"glibc"})
npm ERR! notsup Valid os:    linux
npm ERR! notsup Actual os:   linux
npm ERR! notsup Valid cpu:   x64
npm ERR! notsup Actual cpu:  x64
npm ERR! notsup Valid libc:  musl
npm ERR! notsup Actual libc: glibc

该问题源于@css-inline/css-inline-linux-x64-musl@0.12.1依赖要求musl libc,但当前GitHub Actions运行环境使用的是glibc。尝试使用musl镜像修复时,又遇到Node.js依赖GLIBC版本不足的错误:

/__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__e/node20/bin/node)

解决方案

方案一:使用之前成功的Ubuntu-22.04特定版本部署

直接复用验证有效的runner环境,步骤如下:

  1. 修改GitHub Actions工作流中的runs-on配置,替换ubuntu-latest为指定版本的Ubuntu 22.04 runner:
    name: firebase Continuous Deployment
    
    on:
      push:
        branches: [master]
    
    jobs:
      deploy:
        # 锁定到20240225.1.0版本的Ubuntu 22.04 runner
        runs-on: ubuntu-22.04@sha256:0bc26f894733742400d029b4d5a8680f3a2f5c9e3d5a5524f84c636d4d46b8c7
        steps:
          - uses: actions/checkout@master
          - uses: actions/setup-node@master
            with:
              node-version: 20
          - run: npm ci
          - run: npm run build
          - uses: w9jds/firebase-action@master
            with: 
              args: deploy
            env:
              FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
    
    (注:上述哈希值对应20240225.1.0版本的Ubuntu 22.04托管runner,若版本更新可从GitHub Actions Runner Images仓库获取对应哈希)
  2. 提交修改后的工作流文件,重新触发部署即可。

方案二:修复依赖的libc兼容问题

如果不想锁定runner版本,可通过以下两种方式解决依赖兼容问题:

方法A:重新生成适配glibc的package-lock.json

  1. 在本地glibc系统(如Ubuntu、Debian)执行以下命令:
    rm -rf node_modules package-lock.json
    npm install
    
  2. 将新生成的package-lock.json提交到GitHub仓库
  3. 重新运行部署工作流

方法B:强制npm安装glibc适配版本

修改工作流中的npm ci步骤,添加平台和libc参数:

- run: npm ci --platform=linux --libc=glibc

该参数会强制npm忽略锁文件中指定的musl依赖,安装适配glibc环境的版本。


内容的提问来源于stack exchange,提问作者Hugh Herschell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 21:05:16