-1

I have installed firebase by running npm install -g firebase-tools and other command, but somehow I still cannot run any firebase command in my ionic project directory as a error message will show

'firebase' is not recognized as an internal or external command,operable program or batch file.

Turnout the firebase has been install to other directory instead of my project directory. That's why I cannot run firebase command in my project directory. I can only run firebase command in the installed directory.

Anyone know how to install firebase to a specific project directory? I have done some research. Some of the solution is to modify code in firebase.json file, but my firebase.json file is empty and I tried to change the code like this but it still does work.

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

--

-- npm install firebase-toolsdoes not work for me,this is the result:

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.
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
10IEI
  • 21
  • 1
  • 5
  • Does this answer your question? [Error: not recognized as an internal or external command](https://stackoverflow.com/questions/44603218/error-not-recognized-as-an-internal-or-external-command) – Prabhjot Singh Kainth Dec 13 '19 at 13:05
  • It does not answer my question,the answer is like how to install firebase CLI but I am already installed it and I need to change the directory where it has been installed or else I am unable to run any firebase command in my project directory. – 10IEI Dec 13 '19 at 14:59
  • It looks like there is something wrong with your node installation, or your PATH isn't configured correctly for global installations. – Doug Stevenson Dec 13 '19 at 16:13
  • yeah I think so ,my global installation is C:/program files/git/usr/local, I forgot what command I typed to make the PATH become like that. – 10IEI Dec 13 '19 at 16:17

2 Answers2

0

If you run npm install -g, it is NPM that determines where the package/tool is installed. Firebase has no control over that.

If you want to install the Firebase CLI in the local project direction, run the npm install command with the -g option:

npm install firebase-tools
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I think you're struggling with how NPM works in general. I recommend taking a look at Firebase's recently released [standalone binary version of the CLI for Windows](https://firebase.google.com/docs/cli#install-cli-windows), which precisely tries to address some of these path related problems. – Frank van Puffelen Dec 13 '19 at 16:59
0

use npx firebase login and install firebase tools without -g