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 ?
4 Answers 4
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
Comments
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.
Comments
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 )
Comments
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'?
npm installinside of your local functions folder?npm i --save firebase-functionsinside of the folder also?