Error parsing triggers: Cannot find module 'google-auth-library' - firebase

I have downloaded a full project that has been in use for about a year now, I got a new computer and am trying to upload a change to a function. I had errors and now I am trying to redeploy a function that I know works and is the same as the source in Google Cloud.
I run:
firebase deploy --only functions:generateThumbnail
and this is the output:
deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
Error: Error parsing triggers: Cannot find module './dnssec'
Try running "npm install" in your functions directory before deploying.
I run npm install:
npm WARN functions# requires a peer of eslint#2.x but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN firebase-functions#0.8.2 requires a peer of firebase-admin#~5.10.0 but none is installed. You must install peer dependencies yourself.
audited 7867 packages in 6.019s
found 20 vulnerabilities (3 low, 17 moderate)
run `npm audit fix` to fix them, or `npm audit` for details
then I ran npm audit fix:
npm WARN functions# requires a peer of eslint#2.x but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN firebase-functions#0.8.2 requires a peer of firebase-admin#~5.10.0 but none is installed. You must install peer dependencies yourself.
removed 1 package and updated 5 packages in 7.583s
fixed 8 of 20 vulnerabilities in 7867 scanned packages
2 package updates for 12 vulns involved breaking changes
(use `npm audit fix --force` to install breaking changes; or do it by hand)
..I am still getting the same error as before:
Error: Error parsing triggers: Cannot find module './dnssec'

Hey so I think this is an issue with npm not updating the packages correctly. I was running into the same error.
Error: Error parsing triggers: Cannot find module './dnssec'
I found that the dnssec resource is within the 'sshpk' node module folder. So in order to correct the error I just went into the node_modules folder of my functions directory and removed the 'sshpk' module, and while still in the functions directory ran 'npm install'. Hopefully this works for you and some other people running into this issue.
Cheers. Good luck!

Related

Unable to install Firebase

I am unable to install firebase tool.
> C:\Users\Mohit Saini>npm i -g firebase-tools
> npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
> npm ERR! Unexpected end of JSON input while parsing near '...ePY2w==","shasum":"89'
firstly run npm cache clean --force to clear previous caches
after that run npm cache verify which will bring 0 bytes indicating all cache was cleared.
lastly run npm install -g firebase-tools
note: running the clean --force command will deletes all data from your cache folder.
When I search for the error message, this Github issue shows up: https://github.com/firebase/firebase-tools/issues/2215, which seems to indicate the problem can be fixed by running:
npm cache verify
If you get problems installing the CLI, and are not familiar enough with the environment to fix them, I'd recommend installing the standalone binary version of the Firebase CLI instead.

Connecting Firebase to an React Native App that's using Expo

I am currently trying to connect Firebase to my React Native app that uses Expo. Im currently using this guide: https://docs.expo.io/guides/using-firebase/?fbclid=IwAR0c7g8a-005utr_ROomb_k3ptlAHel3kq004AtFbNkV9iWREeapzR0Dabg and it lead me to the github "Firebase JS SDK". I downloaded the whole github repo (https://github.com/firebase/firebase-js-sdk) and like tried following the instructions on the github such as downloading node, yarn, and java but I am confused on what to do next with the downloaded repo. I have tried running the command "npm install" to try and install the dependencies but I get this error:
npm WARN deprecated tslint#6.1.2: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated request#2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated mkdirp-promise#5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm ERR! Unexpected end of JSON input while parsing near '...cMP/3jKIr36/huSPHVVgD'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ban-Jian\AppData\Roaming\npm-cache\_logs\2020-05-19T23_15_25_175Z-debug.log
And when I run the command: "yarn build" I get this error:
lerna ERR! yarn run build exited 2 in '#firebase/firestore'
lerna ERR! yarn run build stdout:
$ tsc -m es2015 --moduleResolution node scripts/*.ts
error TS6053: File 'scripts/*.ts' not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run build stderr:
error Command failed with exit code 2.
lerna ERR! yarn run build exited 2 in '#firebase/firestore'
lerna WARN complete Waiting for 4 child processes to exit. CTRL-C to exit immediately.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I guess my question is: How do I properly set up the SDK I downloaded from the github?

Import firebase/app used to work now I got error (firestore is not a function)?

I am using React and Redux.
I imported firebase using import shown below:
import * as firebase from 'firebase/app'
import 'firebase/firestore'
Everything was working then I committed changes and pushed them to GitHub. My colleague pulled the code and told me to test it and it was not working. I tried to run the code but not working.
I changed the import to:
import * as firebase from 'firebase/firebase'
import 'firebase/firestore'
the code is working now.
If anyone has an idea what is the reason for this error can you please help me to understand this issue.
I deleted package-lock.json file
Then run npm install
I received this warning
npm WARN #firebase/firestore#1.0.6 requires a peer of #firebase/app#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/firestore#1.0.6 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/auth#0.9.4 requires a peer of #firebase/app#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/functions#0.4.1 requires a peer of #firebase/app#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/functions#0.4.1 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/messaging#0.3.13 requires a peer of #firebase/app#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/messaging#0.3.13 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/storage#0.2.10 requires a peer of #firebase/app#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/storage#0.2.10 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/auth-types#0.5.3 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/auth-types#0.5.3 requires a peer of #firebase/util#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/firestore-types#1.0.3 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/messaging-types#0.2.6 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/storage-types#0.2.6 requires a peer of #firebase/app-types#0.x but none is installed. You must install peer dependencies yourself.
npm WARN #firebase/storage-types#0.2.6 requires a peer of #firebase/util#0.x but none is installed. You must install peer dependencies yourself.
I re-installed firebase
npm install --save firebase
and problem solved. No warnings or errors and it is back to work as before.

Firebase functions deploy npm error

npm WARN ajv-keywords#3.1.0 requires a peer 0f ajv#A6.0.0 but none is installed.
You must install peer dependencies yourself.
Install ajv package before running application. ajv-keywords need it first

Firebase config variables are not available error with deploying functions

When I am deploying Firebase functions without
admin.initializeApp(functions.config().firebase);
Firebase logs
Error: The default Firebase app does not exist. Make sure you call
initializeApp() before using any of the Firebase services.
But if I add that line I get error on deploy.
>firebase deploy --only functions
Error:
Error: Error occurred while parsing your function triggers. Please
ensure you have the latest firebase-functions SDK by running "npm i
--save firebase-functions#latest" inside your functions folder.
Error: Firebase config variables are not available. Please use the
latest version of the Firebase CLI to deploy this function.
I already did npm i --save firebase-functions#latest which haven't done anything. I am stuck and can't do anything right now because of this... I am down for any reinstalls if they could help just tell me some steps or hints and I would seek for the rest.
NPM and NodeJS versions are:
node -v
v8.9.1
npm -v
5.6.0
Edit. Installation with admin rights:
npm i --save firebase-functions#latest
npm WARN firebase-functions#0.8.1 requires a peer of firebase-admin#~5.8.1 but none is installed. You must install peer dependencies yourself.
npm ERR! path C:\Users\Telion\firebaseApps\project-name\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\abbrev
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Telion\firebaseApps\project-name\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\abbrev' -> 'C:\Users\Telion\firebaseApps\project-name\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\.abbrev.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
It actually appeared I was on npm version 5.5.1 but even after the update to 5.6.0 I got the exact same error.
There was a breaking change introduced in firebase-tools#3.17.x which requires your project to upgrade firebase-functions to the latest version.
However, firebase-functions#latest also requires firebase-admin#latest (at the time of writing this answer firebase-admin#5.11.0. Once all packages are upgraded, this problem should be solved.
Another alternative is to downgrade your global firebase-tools to 3.16.0, which lets you use older firebase-functions and firebase-admin packages.
I ran into the same issue in Ubuntu and this is how i solved it
Install firebase using : sudo npm install -g firebase-tools
Also make sure you launch using admin privileges e.g to login
sudo firebase login
You also need to update the node to at least 8.15.x. That detail is shown in the message.
Once I intalled that I had to do a firebase login command and after that you can run the firebase init hosting
Previously I was getting the error on firebase init hosting but after that node update, it went away.
Hope it helps.
For me, it worked for firebase-tools6.9.2.
The firebase-tools3.16.0 is completely depricated.

Resources