Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase function issue?

Tags:

i functions: Preparing to emulate functions. Warning: You're using Node.js v8.10.0 but Google Cloud Functions only supports v6.11.5.

⚠ functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.

⚠ functions: Error from emulator. Error parsing triggers: Cannot find module '/home/developer/Development/host2/functions'

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

We are new in firebase function , How to solve this issue ?

like image 686
Valyangadi Developer Support Avatar asked May 13 '18 08:05

Valyangadi Developer Support


2 Answers

In many cases, new features and bug fixes are available only with the latest version of the Firebase CLI and the firebase-functions SDK. It's a good practice to frequently update both the Firebase CLI and the SDK with these commands inside the functions folder of your Firebase project:

npm install -g firebase-tools
npm install firebase-functions@latest firebase-admin@latest --save

visit: https://firebase.google.com/docs/functions/get-started

like image 99
Kush Avatar answered Oct 02 '22 13:10

Kush


I don't know if my problem was the same as your, but for further reference I will post my solution.

In my case, I was using TypeScript instead of JavaScript, so the code needed to be compiled before run firebase serve.

In your Firebase app directory:

$ cd functions/
$ npm run-script build
$ cd ..
$ firebase serve

The last command maybe need super user permission, so sudo firebase serve.

Optionally you can run npm run-script lint before npm run-script build to check for possible errors if you are using tslint.

like image 26
caiofilipemr Avatar answered Oct 02 '22 13:10

caiofilipemr