5

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 ?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    Did you try as it says to run the `npm install` inside of your local functions folder? – Alex Mounir May 13 '18 at 08:23
  • yes, and nothing happened – Valyangadi Developer Support May 13 '18 at 08:26
  • and `npm i --save firebase-functions` inside of the folder also? – Alex Mounir May 13 '18 at 08:27
  • 303 sudo firebase serve --only functions,host 304 cd functions 305 npm i --save firebase-functions 306 cd ../ 307 ls 308 sudo firebase serve --only functions,host 309 npm i --save firebase-functions – Valyangadi Developer Support May 13 '18 at 08:29
  • not working, it still shows 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. – Valyangadi Developer Support May 13 '18 at 08:29

4 Answers4

3

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

Kush
  • 355
  • 2
  • 20
2

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.

caiofilipemr
  • 190
  • 2
  • 10
0

In my case the solution was :

1 - Reinstall Node ( version 10.15.0 ). After download node-v8.11.2-x64.msi from node.org

2 - Reinstall firebase-tools ( npm install firebase-tools -g )

3 - Clear cache ( npm cache clear --force )

GCoe
  • 849
  • 4
  • 14
  • 30
-1

I was having this problem too. I can't explain how, but it turns out that my firebase.json was not correct. Check the functions section of it and make sure it looks like this:

"functions": {
    "source": "functions"
},

Found this SO answer: How to deploy functions from other directory than '/functions'?

Martavis P.
  • 1,708
  • 2
  • 27
  • 45