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

Ubuntu系统中npm安装Firebase CLI失败及升级Node后新错误求助

Fixing Firebase CLI Installation Errors on Ubuntu

Hey there, let's work through these Firebase CLI installation issues step by step—both the initial rollbackFailedOptional error and the new fetchMetadata : sill resolveWithNewModule problem after upgrading Node.js.

1. Fixing the rollbackFailedOptional Error (Node 8.9.4 / npm 5.6.0)

This error usually stems from corrupted npm cache, permission issues, or compatibility gaps between older Node/npm versions and Firebase Tools. Even though you've upgraded Node, here's how you'd fix it if you ever need to revert or hit this again:

  • Clear the npm cache forcefully:
    npm cache clean --force
    
  • Uninstall any partial or broken Firebase Tools installation:
    npm uninstall -g firebase-tools
    
  • Reinstall with elevated permissions and the --unsafe-perm flag (critical for global installs on Ubuntu, as npm switches to a non-root user for script execution by default):
    sudo npm install -g firebase-tools --unsafe-perm
    

2. Fixing the fetchMetadata : sill resolveWithNewModule Error (Node 9.5.0)

This error means npm is getting stuck trying to resolve package metadata. It's almost always related to cache issues or network problems. Try these solutions in order:

Option 1: Wipe Cache and Reinstall

  1. Clear the npm cache again (sometimes the first clean doesn't get everything):
    npm cache clean --force
    
  2. Delete the entire npm cache directory to ensure no leftover corrupted data:
    rm -rf ~/.npm
    
  3. Reinstall Firebase Tools with verbose logging to track progress (helpful if it gets stuck again):
    sudo npm install -g firebase-tools --unsafe-perm --verbose
    

Installing Node via Ubuntu's system package manager often leads to permission and compatibility headaches. NVM (Node Version Manager) lets you easily switch Node versions without sudo issues:

  1. Install NVM with the official script:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    
  2. Refresh your terminal session to activate NVM (or run this command):
    source ~/.bashrc
    
  3. Install your desired Node version (9.5.0, or a more stable LTS version like 10.x since 9.x is non-LTS):
    nvm install 9.5.0
    
    Or for an LTS release:
    nvm install --lts
    
  4. Set it as your default Node version:
    nvm alias default 9.5.0
    
  5. Now install Firebase Tools without sudo—no permission issues needed:
    npm install -g firebase-tools
    

Option 3: Switch to a Domestic npm Registry (If Network is the Issue)

If npm can't reach the official registry due to network restrictions, switch to a faster domestic mirror:

npm config set registry https://registry.npmmirror.com

Then run the installation command again:

sudo npm install -g firebase-tools --unsafe-perm

Once you've tried these steps, verify the installation worked with:

firebase --version

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 04:36:08