【问题标题】:How to change the directory of my installed firebase?如何更改我安装的 Firebase 的目录?
【发布时间】:2019-12-13 13:02:14
【问题描述】:

我已经通过运行 npm install -g firebase-tools 和其他命令安装了 firebase,但不知何故,我仍然无法在我的 ionic 项目目录中运行任何 firebase 命令,因为会显示错误消息

'firebase' 不是内部或外部命令、可运行程序或批处理文件。

原来 firebase 已安装到其他目​​录而不是我的项目目录。这就是为什么我不能在我的项目目录中运行 firebase 命令的原因。我只能在安装目录下运行 firebase 命令。

有人知道如何将 firebase 安装到特定的项目目录吗?我做了一些研究。一些解决方案是修改 firebase.json 文件中的代码,但我的 firebase.json 文件是空的,我尝试像这样更改代码,但它仍然有效。

{
  "hosting": {
    "public": "C:/Users/CJ/desktop/fyp"
  }
}

--

-- npm install firebase-tools对我不起作用,这是结果:

C:\Users\CJ\Desktop\fyp\tools\functions>npm install firebase-tools
npm WARN firebase-functions@3.3.0 requires a peer of firebase-admin@^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ firebase-tools@7.10.0
updated 1 package and audited 6497 packages in 54.671s

1 package is looking for funding
  run `npm fund` for details

found 200 vulnerabilities (122 moderate, 78 high)
  run `npm audit fix` to fix them, or `npm audit` for details

C:\Users\CJ\Desktop\fyp\tools\functions>firebase
'firebase' is not recognized as an internal or external command,
operable program or batch file.

【问题讨论】:

  • 它没有回答我的问题,答案就像如何安装 firebase CLI 但我已经安装了它,我需要更改它的安装目录,否则我无法运行任何我的项目目录中的 firebase 命令。
  • 您的节点安装似乎有问题,或者您的 PATH 没有为全局安装正确配置。
  • 是的,我想是的,我的全局安装是 C:/program files/git/usr/local,我忘记输入了什么命令使 PATH 变成这样。

标签: node.js windows firebase firebase-cli


【解决方案1】:

如果您运行npm install -g,则由 NPM 确定软件包/工具的安装位置。 Firebase 无法控制。

如果您想在本地项目方向安装 Firebase CLI,请运行带有-g 选项的npm install 命令:

npm install firebase-tools

【讨论】:

【解决方案2】:

使用 npx firebase 登录 并在没有 -g 的情况下安装 firebase 工具

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    相关资源
    最近更新 更多