Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Firebase not found error while deploying functions in firebase

I am trying to host a app in firebase and its giving me error that

Error: Error parsing triggers: Cannot find module 'firebase'

Try running "npm install" in your functions directory before deploying.

I have executed npm install command several times but nothing new.

enter image description here

Please help

like image 948
Mohammed Rampurawala Avatar asked Mar 15 '17 11:03

Mohammed Rampurawala


4 Answers

Cannot find module 'firebase-functions' means that you need to install packages. In your project directory run

$ cd functions
$ npm install

then return back and fire!

$ firebase deploy

Happy coding!

like image 72
ArtemKha Avatar answered Oct 21 '22 14:10

ArtemKha


By default, the firebase dependency isn't in your functions/package.json. Instead, you'll find it lists firebase-admin, the specialized server-side Firebase SDK which is the one we recommend using.

If you really do want to use the firebase client-side SDK instead of firebase-admin, you'll want to run npm install --save firebase in your functions/ directory. You should then have a line in your functions/package.json that looks a bit like this:

{
  ...
  "dependencies": {
    "firebase": "^3.7.2",
    ...
  },
  ...
}
like image 44
Robert-Jan Huijsman Avatar answered Oct 21 '22 13:10

Robert-Jan Huijsman


Although this is coming late, but it's for those who might face the same issue. This worked for me. I added this to my package.json file in folder function.

 {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "dependencies": {
    "firebase-admin": "~5.2.1",
    "firebase-functions": "^0.6.2",
    "mkdirp": "^0.5.1",
    "mkdirp-promise": "^4.0.0"
  },
  "private": true
}

Then run: npm install in folder function

like image 5
Prodigy Avatar answered Oct 21 '22 15:10

Prodigy


Clean up node_modules,

rm -rf package-lock.json
rm -rf node_modules

Update functions/package.json file with latest or compatible versions of dependencies with your node version and run npm install from functions folder.

Try firebase deploy now. Should be good!

like image 3
Kiran Kuyate Avatar answered Oct 21 '22 15:10

Kiran Kuyate