Firebase-functions: Can't serve firebase-functions locally, even with Node v6.11

Created on 30 Jul 2017  Â·  66Comments  Â·  Source: firebase/firebase-functions

[email protected]
[email protected]
[email protected]

Test case

Trying to serve functions locally

Steps to reproduce

Install nvm
nvm use v6.9.1
install dependencies
now run:
firebase serve --only functions

Expected behavior

That the functions are hosted locally

Actual behavior

The log file is deleted, but I get this output:

=== Serving from '/Users/alexbjorlig/Documents/Github/amentoCph'...

i functions: Preparing to emulate HTTPS functions. Support for other event types coming soon.
Node.js v6.11.x or greater is required to run the Emulator!
âš  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. Please note that emulation of custom config values are not supported yet. Run firebase serve --only hosting to only serve hosting files.

Error: Emulator crashed! Check the log file...
i functions: No HTTPS functions emulated. Support for other function types are coming soon.

```

Most helpful comment

is this resolved? still getting the same problem

All 66 comments

As the error message says, you need v6.11.x or higher to run the emulator.

Same error, and my node is v6.11.

Same here

@robsonataide @jasenkoh what are your exact node versions?

@laurenzlong 6.11

Can you give me the patch version as well? (ie what gets printed when you run node --version)

@laurenzlong v6.11.0

@jasenkoh Same issue

@jasenkoh @tysonnero Does the problem go away if you update to 6.11.1?

We have a dependency on the Google Cloud Functions emulator, and 6.11.1 is the minimum engine requirement: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/blob/master/package.json#L8

@laurenzlong worked for me, thanks

I'm suffering from the same issue:

node [email protected]
[email protected]
[email protected]
[email protected]

Then:
firebase serve --only functions

i functions: Preparing to emulate functions.
âš  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
at Error.FirebaseError (/usr/local/lib/node_modules/firebase-tools/lib/error.js:11:17)
at ChildProcess. (/usr/local/lib/node_modules/firebase-tools/lib/parseTriggers.js:24:16)

@laurenzlong - You're my only hope!

@aliparr- Same issue

@DenisCangemi @aliparr- Were you able to deploy these functions successfully?

@laurenzlong yes, deploy works correctly

@laurenzlong +1 - deploy works fine for me too.

is this resolved? still getting the same problem

I am facing the same issue, Funny thing is if I skip initializing firebase admin it executes just fine.
node 6.11.1
firebase-admin 5.2.1
firebase-functions 0.6.2

Update: I checked my code and found out that the issue had to do with some other module i was importing.

I updated my node version to v8.6.0 and all of my problems were gone.

@dhargitai Really? If I do that I get:

"âš  functions: Cannot start emulator. Please use Node version v6.9.1, you have v8.6.0"

@aliparr- I did get this message too but I get only a warning now: _Warning: You're using Node.js v8.6.0 but Google Cloud Functions only supports v6.11.1._

Other version numbers at me:
npm: 5.3.0
firebase-tools: 3.12.0
firebase-admin 5.2.1
firebase-functions 0.6.3

Here's what I did:

functions stop
npm uninstall -g @google-cloud/functions-emulator
rm ~/.config/configstore/@google-cloud/functions-emulator
npm uninstall -g firebase-tools
npm cache clean -f
rm -rf functions/node_modules
npm i -g firebase-tools
npm i -g @google-cloud/functions-emulator
cd functions
npm i

Hope this helps.

Having the same issue, but using NVM. Ran @dhargitai instructions on both 8.6.0 and 6.11.1 with the same result. Checked for any globals residing in /usr/local/lib/node_modules that shouldn't be there, but just npm as it should be. npm correctly installs firebase-functions 0.7.0 in functions/node_modules. firebase-tools is 3.13.0.

This has been happening to me every time my code breaks. And every time it gets solved after I debug.

@Nipperstick I just checked it with updated versions and everything works correctly at me.

Version numbers:

  • nvm: 0.33.4
  • firebase-tools: 3.13.0
  • firebase-admin: 5.4.1
  • firebase-functions: 0.7.0

Yep, I discovered that my code had issues, but that the error wasn't being displayed. I had to add a console.log inside of parseTriggers to see the actual error text. Perhaps we could just ensure that gets to the screen for the developer?

I suffered from similar problem too. My IDE inserted the import of the firebase-admin package incorrectly (as relative module path), and I got

"âš  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."

message constantly. Not too developer-friendly error.

Thanks for the update! Error messaging fixed here https://github.com/firebase/firebase-tools/pull/490

@laurenzlong Same issue:

[email protected]
[email protected]
[email protected]
node@8.*

run firebase serve --only functions

output:

i  functions: Preparing to emulate functions.
Warning: You're using Node.js v8.1.3 but Google Cloud Functions only supports v6.11.5.
âš   functions: Failed to emulate helloWorld

while if i switch to node@6.*

âš   functions: Cannot start emulator. Error: Cannot find module '/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/src/node/extension_binary/node-v48-darwin-x64-unknown/grpc_node.node'

when i go to /usr/local/lib/node_modules/firebase-tools/node_modules/grpc/src/node/extension_binary i only got node-v57-darwin-x64-unknown instead of node-v48-darwin-x64-unknown

@Kar1Huang Can you file that as an issue on https://github.com/GoogleCloudPlatform/cloud-functions-emulator?

It worked with following:

npm install -g firebase-tools
nvm install 6.11.5

doenst work for me :(

i  functions: Preparing to emulate functions.
Warning: You're using Node.js v8.6.0 but Google Cloud Functions only supports v6.11.5.
âš   functions: Failed to emulate getWeather

Are you using nvm? If so, use the following:

nvm install 6.11.5

and then give it a try. Hope that helps!

Using with 6.11.5 , It works.

@Kar1Huang
When you switch from one version of node to a other one you need to re-install firebase-tools
that's why you don't have the correct folder

on nvm 6.11.1
npm uninstall -g firebase-tools
npm install -g firebase-tools
nvm use 6.11.5
Finally resolved it for me

thanks guys, but still doesnt work for me

âš   functions: Failed to emulate getWeather

why this issue has been closed? I reckon issue is still valid for many devs:

[warn] ! functions: Failed to emulate hello

node v6.11.5
firebase-tools 3.16.0
"firebase-admin": "^5.5.0",
"firebase-functions": "^0.7.5"

@Kar1Huang @flado It's unclear that you're facing the same issue as the original issue here. Could you please ensure that you have the latest firebase-tools by running npm install -g firebase-tools. And file any new issues to the firebase-tools repo instead of this one, and follow the issues template completely so all the debug logs are captured.

I updated my node version to 8.4.0 and it worked fine, despite cloud functions not "supporting" 8.4.0
Edit: with a version manager like nvm or n it's no biggy switching between versions

nothing helps...
node v6.11.5 (npm v5.6.0)
[email protected]
[email protected]
[email protected]

this is the last lines of firebase-debug.log

[debug] [2018-01-30T00:34:31.550Z] Starting @google-cloud/functions-emulator
[debug] [2018-01-30T00:34:32.822Z] Parsing function triggers

firebase serve --only function gets me that far and then it hangs up. in the terminal it just stops at i functions: Preparing to emulate functions.

What to do? What to do? Help please.

Same here like @ohabash

brew unlink
brew switch node@6 6.11.1_1
brew link node@6 --force
other steps for uninstall and install dependencies
node v6.11.1_1
npm 5.6.0
firebase-admin 5.8.2
firebase-functions 0.8.1
firebase-tools 3.17.4

firebase serve --only functions,hosting then i functions: Preparing to emulate functions. is the last message for functions. If I trigger something, only deployed one runs and nothing on local side.

firebase-debug.log says (head)

[debug] [2018-02-13T01:11:08.276Z] -------------------------------------------------------------------
---
[debug] [2018-02-13T01:11:08.278Z] Command:       /usr/local/Cellar/node@6/6.11.1_1/bin/node /usr/loca
l/bin/firebase serve --only functions,hosting
[debug] [2018-02-13T01:11:08.278Z] CLI Version:   3.17.4
[debug] [2018-02-13T01:11:08.278Z] Platform:      darwin
[debug] [2018-02-13T01:11:08.278Z] Node Version:  v6.11.1
[debug] [2018-02-13T01:11:08.279Z] Time:          Tue Feb 13 2018 10:11:08 GMT+0900 (KST)
[debug] [2018-02-13T01:11:08.279Z] -------------------------------------------------------------------
---
[debug]

and nothing thereafter even I trigger something on realtime database...

Don't know why but installing firebase-tools in node v9.6.1 fix the problem, now npm start works for bothnode v6.11.5 and node v9.6.1.

When I install firebase-tools in v9 shows me some compilation messages but this doesn't happen with v6. Anyway now it's working at last (I spend almost 5 hours looking for a solution).

Hope this "solution" helps someone else.

I was having same issues as @hansanghoon and @ohabash.
Hang after 'Parsing function triggers'...

node v6.11.5
npm 3.10.10
firebase-admin 5.8.2
firebase-functions 0.8.1
firebase-tools 3.17.6

Then I finally saw this.

Ok, my function IS NOT an HTTP function so the hang there is currently expected behavior.
Hope this helps someone else.

In the spirit of "Don't Be Evil", would hope to see an error message or a warning or something other than hang.

A note for anyone here using TypeScript like I was: you need to run npm run build in the functions directory before running serve.

After trying just about everything, ps ax | grep firebase , kill -9 xxxx all existing firebase processes and running firebase serve again did the trick.

I had not done used firebase for a while - so just a reminder, once you run "firebase serve --only functions" , make sure that you load the url given i.e. " http://localhost:5000/*/*/functionYouAreRunning " in your browser to trigger the request

➜  Vue-Fullstack-Starter git:(develop) firebase serve --only functions

=== Serving from '/Users/shyamchen/Desktop/Vue-Fullstack-Starter'...

i  functions: Preparing to emulate functions.
âš   functions: Failed to emulate api
âš   functions: Failed to emulate app

➜  Vue-Fullstack-Starter git:(develop) node -v
v6.14.2
➜  Vue-Fullstack-Starter git:(develop) npm -v
3.10.10
➜  Vue-Fullstack-Starter git:(develop) yarn -v
1.3.2

@Shyam-Chen Please run again with --debug flag and file a new issue.

Same error than @Shyam-Chen. How did you manage to fix the issue?

C:\Program Files\nodejs\project\functions>firebase serve --only functions --debug
[2018-05-19T23:29:38.959Z] ----------------------------------------------------------------------
[2018-05-19T23:29:38.962Z] Command: C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\project\node_modules\firebase-tools\bin\firebase serve --only functions --debug
[2018-05-19T23:29:38.963Z] CLI Version: 3.18.4
[2018-05-19T23:29:38.963Z] Platform: win32
[2018-05-19T23:29:38.963Z] Node Version: v10.1.0
[2018-05-19T23:29:38.963Z] Time: Sun May 20 2018 01:29:38 GMT+0200 (Paris, Madrid (heure d’été))
[2018-05-19T23:29:38.963Z] ----------------------------------------------------------------------

(node:14048) ExperimentalWarning: The fs.promises API is experimental
[2018-05-19T23:29:38.978Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-05-19T23:29:38.978Z] > authorizing via signed-in user
[2018-05-19T23:29:38.981Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/project-11b1e

Sun May 20 2018 01:29:38 GMT+0200 (Paris, Madrid (heure d’été))
[2018-05-19T23:29:39.654Z] <<< HTTP RESPONSE 200 server=nginx, date=Sat, 19 May 2018 23:29:41 GMT, content-type=application/json; charset=utf-8, content-length=114, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-05-19T23:29:39.656Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/project-11b1e/tokens

Sun May 20 2018 01:29:39 GMT+0200 (Paris, Madrid (heure d’été))
[2018-05-19T23:29:40.228Z] <<< HTTP RESPONSE 200 server=nginx, date=Sat, 19 May 2018 23:29:42 GMT, content-type=application/json; charset=utf-8, content-length=264, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-05-19T23:29:40.229Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/project-11b1e

Sun May 20 2018 01:29:40 GMT+0200 (Paris, Madrid (heure d’été))
[2018-05-19T23:29:40.958Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 19 May 2018 23:29:42 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close

=== Serving from 'C:\Program Files\nodejs\project'...

i functions: Preparing to emulate functions.
[2018-05-19T23:29:41.596Z] Fetching environment
[2018-05-19T23:29:41.598Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/300108879366:getServerAppConfig

Sun May 20 2018 01:29:41 GMT+0200 (Paris, Madrid (heure d’été))
[2018-05-19T23:29:42.094Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 19 May 2018 23:29:44 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-19T23:29:42.094Z] Starting @google-cloud/functions-emulator
Warning: You're using Node.js v10.1.0 but Google Cloud Functions only supports v6.11.5.
[2018-05-19T23:29:43.615Z] Parsing function triggers
[2018-05-19T23:29:44.130Z] Error while deploying to emulator: RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2185921453
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2185921453
at checkInt (internal/buffer.js:35:11)
at writeU_Int32LE (internal/buffer.js:515:3)
at Buffer.writeInt32LE (internal/buffer.js:684:10)
at Object.entryHeaderToBinary (C:\Program Files\nodejs\project\node_modules\adm-zip\headers\entryHeader.js:216:18)
at Object.packHeader (C:\Program Files\nodejs\project\node_modules\adm-zip\zipEntry.js:260:39)
at C:\Program Files\nodejs\project\node_modules\adm-zip\zipFile.js:198:41
at Array.forEach ()
at Object.compressToBuffer (C:\Program Files\nodejs\project\node_modules\adm-zip\zipFile.js:182:23)
at Object.writeZip (C:\Program Files\nodejs\project\node_modules\adm-zip\adm-zip.js:454:32)
at client.generateUploadUrl.then.then (C:\Program Files\nodejs\project\node_modules\@google-cloud\functions-emulator\src\cli\controller.js:168:13)

! functions: Failed to emulate api

Could you try switching your Node version to v6.11.5, which is the recommended version for emulating functions?

Not needed, as this hotfix works:
https://github.com/firebase/firebase-tools/issues/770#issuecomment-390622784

Is Firebase going to upgrade to Node v8.11.1 ??

@LaZeR30 The NodeJS team has a Release repo where you can review the planned lifespan of each LTS release.

Right now, v6.x.x has a sunset date of April 2019.

Because Firebase Functions needs to continue to support a wide-array of customers that rely on certain versions of node, upgrading is a much more in-depth process that involves active involvement from _every single user of Firebase Functions_ in order to ensure production instances of presently deployed applications aren't affected in the long term from changing LTS version. Although Node v8.x.x has moved into LTS, it won't officially take over until April 2019, at which point the NodeJS team cannot ensure v6.x.x.

My assumption would be that early next year we'll start seeing emails from Google about a forced upgrade from v6.x.x to v8.x.x _Correction: @laurenzlong Mentioned below that a new Node 8 runtime will be supported soon, and there will be no forced upgrade._

If you're having trouble with it on your local machine, I use the n NPM package to switch between versions quickly when I'm developing among multiple applications that rely on varying node engines.

Check it out: https://npmjs.com/package/n

Hey everyone, we are working on a new Node 8 runtime and will support it soon. You will have the option to pick between Node 6 and Node 8 and won't be forced to upgrade.

Great !
Please also consider :

@laurenzlong any suggestions to make it work till the new options are available?

@prakis I would recommend using n (or, alternatively, nvm) when developing with firebase-functions, making sure to using v6.11.x — This is what I've done to get around other issues. Using a transpiler like Babel can help polyfill/transpile features that don't exist in v6.11.x that you may need to leverage.

When developing a firebase-functions application:

$ n 6.11.5
$ node -v
v6.11.5

Other usage examples:

$ n lts
$ node -v
v8.11.3
$ n latest
$ node -v
v10.7.0

It's an extra step, but a solution nonetheless, one that I use without issues.

@Swivelgames Thank you.

I still have same issue. Changing to node 6.11.5 had no effect, same issue.

Firebase worked great for my other project. Now I am not even able to start a new firebase project on Windows.

Hey everyone, Node 8 is now available with the latest SDK and CLI, learn more at https://firebase.google.com/docs/functions/manage-functions#set_nodejs_version

For those that this may help, running firebase serve at the same time as firebase functions:shell will result in these errors.

Thanks to @isabellachen.

I found that if you cd into your functions folder and then run firebase serve, it works.

Was this page helpful?
0 / 5 - 0 ratings