Multiple Versions of Firebase Installed - Which Do I Use? - firebase

I'm trying to build an app with Firebase and ran a few commands to see which version I have. To follow along with a 2021 instruction video, I was hoping to have Firebase v9. Depending on the command that I run, I somehow have versions 8 and 11. If I have these two versions, which one is actually being used? What is the difference between seemingly having an npm firebase and non-npm firebase installed?
armadillo#armadillo-MacBook-Air my-app % npm firebase --version
8.11.0
armadillo#armadillo-MacBook-Air my-app % firebase -V
11.2.2

If you're trying to work with the Firebase CLI, you should be looking at the firebase-tools npm package, not firebase. They are definitely not the same thing.
npm firebase-tools --version
I suggest reviewing the documentation as well.

As covered by #Doug's answer, the firebase command is defined by the firebase-tools npm package (or by https://firebase.tools if installed that way) not the firebase package, which does not define any command line utilities.
Additionally, npm --version returns the version of npm you have installed. This includes if you add the name of a package there. (i.e. npm thisCouldBeAnythingNotANPMCommand --version will return the same result)
If you want to view the version of a deployed package, you would use one of the following commands to query NPM's database:
npm view firebase version (view package's "version" field)
npm v firebase version (view package's "version" field, using shorthand)
npm view firebase (get all available package information)
If you want to view the version of a package installed in your project or globally, you would use:
npm ls firebase (local install)
npm ls -g firebase-tools (global install)
If you want to view the where the npm-installed commands are, you would use:
npm bin (local install)
npm bin -g (global install)
For the firebase command, the firebase/firebase.cmd/firebase.ps1 files all point to <global bin directory>/node_modules/firebase-tools/lib/bin/firebase.js.
Compare the results of:
> npm v firebase version
9.9.0
> npm ls firebase
`-- firebase#9.0.0-beta.6 (an old project directory for another SO answer)
> npm v firebase-tools version
11.2.2
> npm ls -g firebase-tools
`-- firebase-tools#9.21.0 (updated since :D)
> npm --version
6.4.12
> npm firebase --version
6.4.12
> npm v npm version
8.14.0 (updated since :D)

Related

Downgrade Firebase 9.6 to 9.2.0

What commands must I follow on the command line to downgrade. I ran uninstall and reinstalled as well as nom i -S firebase#... but now when I reload the app it just crashes.
If you have to install an older version of a package, just specify it
npm install <package>#<version>
For example: npm install firebase#9.2.0
You can also add the --save flag to that command to add it to your package.json dependencies, or --save --save-exact flags if you want that exact version specified in your package.json dependencies.
The install command is documented here: https://docs.npmjs.com/cli/install
If you're not sure what versions of a package are available, you can use:
npm view firebase versions
And npm view can be used for viewing other things about a package too.
https://docs.npmjs.com/cli/view
don't forget to remove .lock file first to rebuilt the depedency
can u give the error messege for us....

Package.json indicates an outdated version of firebase-functions

I have Cloud functions project and i moved the project from my old laptop to my new laptop.
I have installed everything that necessary. My problem is when i try firebase deploy it gives me that error:
! functions: package.json indicates an outdated version of firebase-functions.
Please upgrade using npm install --save firebase-functions#latest in your functions directory.
I did that i have been told, but still it gives me the same error.
What should i do? And how i direct the npm install to my functions directory?
You need to run sudo npm install --save firebase-functions#latest in your functions directory. Cannot be in any other directory.
In Flutter this will be in
/path_to_your_flutter_project/functions
Hope this helped someone
I had the same problem.
You just need to run npm install -g firebase-tools
npm install -g firebase-tools
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
+ firebase-tools#7.0.0
That fixed my problem.
Update firebase-admin and make sure your root package.json file points to your functions folder

Firebase: Cannot start emulator

functions: Cannot start emulator. Error: Cannot find module '#google-cloud/functions-emulator/src/config'
This is the error message I get when I try to run functions locally on Mac. My Firebase version is 3.16.0. I tried doing sudo npm install -g #google-cloud/functions-emulator as well. But still no use. Please help.
Solution is:
yarn global add firebase-tools
yarn global add #google-cloud/functions-emulator --ignore-engines
Working Solution!(OSX) None of the above worked for me. After a long struggle, I found the following solution.
cd my_project/functions
npm install #google-cloud/functions-emulator
Copy #google-cloud/functions-emulator folder generated inside node_modules.
cd /usr/local/lib/node_modules/#google-cloud && open .
Paste the functions-emulator folder here.
In your project's root directory, copy package.json inside functions/node_modules/#google-cloud/functions-emulator
cd /usr/local/lib && open .
Paste the package.json here.
npm install
Hurray! You are good to go. Now go back to your project's root directory and run.
sudo firebase serve --only hosting,functions
And the emulator should start normally.
Note: Do not run sudo npm install -g #google-cloud/functions-emulator since the files will be removed and reinstalled. This is where the installation fails and emulator fails to run.
Hope this helps!
The following worked for me.
npm uninstall -g firebase-tools && npm i -g firebase-tools
npm i --save #google-cloud/firestore
npm i --save #google-cloud/common-grpc
npm i -g #google-cloud/functions-emulator
npm i --save firebase-functions
current package.json snippet
"dependencies": {
"#google-cloud/common-grpc": "^0.5.3",
"#google-cloud/firestore": "^0.11.1",
"firebase-functions": "^0.8.1",
"firebase-admin": "5.8.1"
}
My system: Ubuntu 16.04.3
I had the same problem and the reason is that "#google-cloud/functions-emulator" is not installed in the 'npm global packages folder'.
In my case it happened because I installed firebase-tools globally using yarn, and I used it because when installing firebase-tools globally using npm I was getting an folder access error, which did not happen with yarn.
What I did to solve the problem was to follow these simple instruction from npm website to use a different folder for npm global packages (https://docs.npmjs.com/getting-started/fixing-npm-permissions).
Then I installed again with 'npm install -g firebase-tools' (without sudo) and it worked perfectly.
I had the same problem, using Ubuntu 17.10.
Note: You do not need to, and should not, use sudo for the installation.
I resolved this by performing the following:
Uninstall any previously attempted installed of the functions emulator.
npm uninstall -g #google-cloud/functions-emulator
and to make sure:
yarn global remove #google-cloud/functions-emulator
Delete all files in ~/.config/configstore/#google-cloud/functions-emulator. Note that there are some hidden files in this directory.
rm -rf ~/.config/configstore/#google-cloud/functions-emulator
Install nvm (node version manager) by following the instructions here:
https://github.com/creationix/nvm#install-script
Use nvm to install a specific version of node - at the time of writing, the Google Cloud Function Emulator (version 1.0.0-alpha.29) specifically requires 6.11.5.
nvm install 6.11.5
Install the Google Cloud Platform SDK:
https://cloud.google.com/sdk/
Reinstall the functions emulator:
npm install -g #google-cloud/functions-emulator
Start the emulator to verify installation has succeeded:
functions start
IMPORTANT: Subsequently, when attempting to create a function that can be tested locally or deployed to Google Cloud, you should use the firebase init functions command within your project, and allow this to install dependencies via npm. A walkthrough of creating a test function with Firebase can be found here:
https://firebase.google.com/docs/functions/get-started

firebase version is not updating through <npm install -g firebase-tools>

i am windows user and trying to update firebase version using
npm install -g firebase-tools but when i run firebase --version
it shows the same version.
I also run npm uninstall firebase --save and check firebase --version it shows same.
what should i do to update my firebase version?
npm update -g firebase-tools
or
npm install -g firebase-tools#3.12.0 to install a specific version
And make sure to restart your terminal/IDE otherwise, it won't take effect.
Have you tried npm update -g firebase-tools? This worked for me.
These days if you're on an older version, and you check the version of firebase-tools, by running:
firebase -V
along with the version of firebase-tools that you're on, it also gives you a messages, something like this:
So you can basically run npm i -g firebase-tools to update the version of your firebase-tools installation to the latest version.
Hope this helps :)
For other like me stumbling in with a weird version mismatch:
When I did firebase -V in my terminal I would get a different version (5.1.1) than when I ran firebase through a npm run script (3.19.3)
The problem was that I had previously installed firebase locally into that project. In other words, I was getting the global version in the terminal, but npm was using the node_modules version
To confirm this, I added a simple test called test-foo to my package.json (firebase -V && which firebase) and ran it:
kuzyn(λ)matebox‡ npm run test-foo
kuzyn-project#1.1.0 test-foo /home/kuzyn/code/kuzyn-project/firebase
firebase -V && which firebase
3.19.3
/home/kuzyn/code/kuzyn-project/firebase/node_modules/.bin/firebase
Then I removed the (uneeded in my case) local firebase package from the package.json and from node_modules
Try the 2 steps bellow
1. yarn/npm cache clean
2. npm install -g firebase firebase-tools or yarn add -g firebase firebase-tools
in a new terminal, firebse --version
works for me
it works to me...
standalone binary: Download the new version, then replace it on your system
if you are using the standalone.Download the new version
In my case I was using an old node version (v10) and had to switch to a newer one (v12). After that I ran npm install -g firebase-tools again and it was updated to the latest version.
You can check the current node version by running node -v. And I use nvm to switch to a different node version.
That might happen in case you've installed the firebase-cli using a so called automatic install script.
Try to call curl -sL https://firebase.tools | upgrade=true bash as described in the official documentation

npm semver version invalid issue with grunt installation

While installing grunt, one of the errors is unmet dependency semver#4
i am using node#0.10.33, npm#1.4.28
i run two commands and it shows two versions and one is invalid
npm list -g
and in the tree it shows semver#2.3.0 invalid
now i run
npm view semver version
now it shows 4.1.0
i tried npm update semver
but nothing happens
i have even tried to the solution provided in similar question npm error invalid semver
curl https://npmjs.org/install.sh | sh
but donesnt help
I am new to npm and grunt please help!
what do you mean by While installing grunt?
Installing the grunt-cli tools or the grunt-runner in your project?
since 4.0 grunt is split into 2 modules:
grunt-cli
grunt
grunt-cli needs to be installed globally, and only 1 time:
$ npm install grunt-cli -g
grunt needs to be installed locally in every project where you want to use grunt and grunt-plugins:
$ npm install grunt
updating npm:
the crazy stuff about npm is, that you can even update npm via npm:
$ npm update npm -g
the current npm version is 2.1.9, so maybe this solves your problem.
hint: use nvm vor node.js version management. this solves multiple problems:
easy version switching
you don't need sudo for global packages

Resources