Firebase-functions: Running the provided https function example locally does not work

Created on 28 Jul 2017  Â·  8Comments  Â·  Source: firebase/firebase-functions

Version info

node: 6.11.0

npm: 3.10.10

firebase-functions: 0.5.9

firebase-tools: 3.10.10

firebase-admin: 4.2.1

Test case

I tried running the (commented out) https function you get by running firebase init functions locally.
Always get the following message (even after installing firebase-functions inside the functions directory:

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...

The Log file is deleted instantly.

Steps to reproduce

mkdir functiontest
cd functiontest
firebase init functions
cd functions
cd ../

commenting out line 6-8 from the generated index.js

firebase serve --only functions
cd functions
npm i --save firebase-functions
cd ../
firebase serve --only functions

Were you able to successfully deploy your functions?

Deploying works as expected.

Expected behavior

Serving the helloWorld function locally.

Actual behavior

see above
The local Log file is deleted instantly.

Most helpful comment

@ubaidazad I came here looking for a solution to the same problem. Switching to node v6.11.5 fixed it for me. Might be worth a shot.

All 8 comments

hey @janrop thanks for reporting, 3.10.10 is not an actual firebase-tools version (see https://github.com/firebase/firebase-tools/releases). Can you run "firebase --version" and update the issue with what it prints out?

Hey @laurenzlong. Sorry that was what npm gave me.
"firebase --version" is 3.9.1

hey @janrop I'm unable to reproduce this. Can you try updating your firebase-tools by running:

npm install -g firebase-tools

There is now a new release of firebase-tools (v.3.9.2) that requires a higher version of google-cloud/functions-emulator, which has some bug fixes.

Please reopen the issue if that doesn't fix it.

EDIT: @laurenzlong So this error occurs when there is some JS error in the bundle code. in my case I was using firebase UI and was generating the error "window not found" since firebaseUI does not support SSR. I think it will be great if the emulator can give the actual stack trace so we know! :)

unfortunately this still happens. this is the error log
âš  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 FirebaseError (/usr/local/lib/node_modules/firebase-tools/lib/error.js:11:17) at ChildProcess.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/parseTriggers.js:24:16) at emitTwo (events.js:125:13) at ChildProcess.emit (events.js:213:7) at emit (internal/child_process.js:774:12) at _combinedTickCallback (internal/process/next_tick.js:141:11) at process._tickDomainCallback (internal/process/next_tick.js:218:9)

This is the same issue as https://github.com/firebase/firebase-tools/issues/482, which I will work on fixing. You can follow the progress there.

still getting the same error in latest firebase-tools

i functions: Preparing to emulate functions.
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.
! functions: Error from emulator. Error: Emulator crashed! Check the log file...
Shutting down...

 node -> v6.11.0
 npm -> 3.10.10
 firebase -> 3.16.0

@ubaidazad I came here looking for a solution to the same problem. Switching to node v6.11.5 fixed it for me. Might be worth a shot.

The node v6.11.5 works for me!

Was this page helpful?
0 / 5 - 0 ratings