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

全局安装firebase-tools失败求助:npm命令执行报错

全局安装firebase-tools失败的解决方法

尝试执行npm install -g firebase-tools全局安装firebase-tools时失败,终端报错信息如下:

> npm install -g firebase-tools
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! path C:\Users\berk.BERK-PC\Desktop\'~\.npm-global'\node_modules\firebase-tools\node_modules\protobufjs
npm ERR! command failed
npm ERR! command C:\Users\berk.BERK-PC\.cache\firebase\runtime/shell.bat -c -- node scripts/postinstall
npm ERR! '--' is not recognized as an internal or external command,
npm ERR! operable program or batch file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\berk.BERK-PC\AppData\Local\npm-cache\_logs\2023-11-09T22_29_32_163Z-debug-0.log

问题根源

报错核心是'--'不被识别为合法命令,且npm全局安装路径中包含非法单引号(Desktop\'~\.npm-global'),导致protobufjs的postinstall脚本执行时路径解析错误。

解决步骤

  • 检查并修正npm全局路径配置
    1. 执行npm config get prefix查看当前全局路径,确认是否存在多余单引号或非法字符
    2. 若路径异常,执行npm config set prefix "C:\Users\berk.BERK-PC\.npm-global"(替换为无特殊字符的合法路径,去掉多余单引号);也可执行npm config delete prefix重置配置后重新设置
  • 清理npm缓存
    执行npm cache clean --force清除缓存,避免残留配置干扰安装
  • 重新安装firebase-tools
    执行npm install -g firebase-tools,若仍失败,尝试以管理员权限打开命令提示符后再执行
  • 备选方案(无需全局安装)
    直接使用npx firebase-tools <具体命令>临时调用firebase-tools功能

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 19:12:15