firebase-tools:
8.3.0 and later
Platform:
Windows
firebase emulators:start
npm i [email protected] -g
firebase emulators:start
D:\workspace\firebasetest>npm i [email protected] -g
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
D:\Users\yang\AppData\Roaming\npm\firebase -> D:\Users\yang\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\firebase-tools\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ [email protected]
added 1 package from 1 contributor, removed 1 package and updated 1 package in 11.003s
D:\workspace\firebasetest>firebase emulators:start
i emulators: Starting emulators: functions, firestore, pubsub
+ hub: emulator hub started at http://localhost:4400
! Your requested "node" version "10" doesn't match your global version "12"
+ functions: functions emulator started at http://localhost:5001
i firestore: firestore emulator logging to firestore-debug.log
+ firestore: firestore emulator started at http://localhost:8080
i firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
i pubsub: pubsub emulator logging to pubsub-debug.log
+ pubsub: pubsub emulator started at http://localhost:8085
i functions: Watching "D:\workspace\firebasetest\functions" for Cloud Functions...
> [functions] Start functions
+ functions[updateRestaurantRate]: firestore function initialized.
+ functions[pubsubFn]: pubsub function initialized.
+ functions[cronRestaurantRanking]: pubsub function initialized.
+ functions[scheduledFunctionCrontab]: pubsub function initialized.
+ emulators: All emulators started, it is now safe to connect.
D:\workspace\firebasetest>npm i [email protected] -g
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
D:\Users\yang\AppData\Roaming\npm\firebase -> D:\Users\yang\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\firebase-tools\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ [email protected]
added 1 package from 1 contributor, removed 1 package and updated 1 package in 9.576s
D:\workspace\firebasetest>firebase emulators:start
i emulators: Starting emulators: functions, firestore, pubsub
! Your requested "node" version "10" doesn't match your global version "12"
i firestore: Firestore Emulator logging to firestore-debug.log
! hosting: The hosting emulator is configured but there is no hosting configuration. Have you run firebase init hosting?
i pubsub: Pub/Sub Emulator logging to pubsub-debug.log
i functions: Watching "D:\workspace\firebasetest\functions" for Cloud Functions...
! TypeError: Cannot convert object to primitive value
at Proxy.<anonymous> (D:\Users\yang\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:311:83)
at Object.<anonymous> (D:\workspace\firebasetest\functions\lib\index.js:13:7)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at D:\Users\yang\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:660:33
at Generator.next (<anonymous>)
! We were unable to load your functions code. (see above)
- You may be able to run "npm run build" in your functions directory to resolve this.
I tired "npm run build" in my functions, it does not work.
D:\workspace\firebasetest>cd functions
D:\workspace\firebasetest\functions>npm run build
> functions@ build D:\workspace\firebasetest\functions
> tsc
Also present in 8.4.0. It was a regression in 8.3.0, and it's not fixed yet :( The solution is to downgrade to 8.2.0
The line shown in the log (\lib\emulator\functionsEmulatorRuntime.js:311:83) points to:
new types_1.EmulatorLog("SYSTEM", "default-admin-app-used", `config=${defaultAppOptions}`, {
opts: defaultAppOptions,
}).log();
which is the compiled version of:
https://github.com/firebase/firebase-tools/blob/710d0f214ae55cdae33f6c2fd69e936668fa3aaa/src/emulator/functionsEmulatorRuntime.ts#L498
I assume the error is being caused by this line:
Because opts has type admin.AppOptions which is an object that contains other objects as fields and maybe JS is failing to get its string value. I think we can solve this by converting opts to string before sending it to the EmulatorLog.
One more thing I noticed is that OP's log shows that they're using Node Version 12, so I assume this occurs on Node >= 12. This StackOverflow question reports the same issue on Node 13.
@rosariopfernandes According to this comment the supported Node.js version is 10:
https://github.com/firebase/firebase-tools/issues/1360#issuecomment-630863472
(Which I am using, but I also see this problem now, with 8.4.0)
For what it's worth, I get the same error with both Node 10 and with Node 12, on both Windows and Mac.
Digging into what @rosariopfernandes described, I tracked my issue down to this line in my code:
admin.initializeApp(functions.config().firebase);
In my case, there was nothing in my firebase function config (I'm thinking I copied that line from an earlier firebase admin tutorial), so I changed the line to:
admin.initializeApp();
and it started working. Obviously not a great solution, especially if you do have actual configuration values you need to pass into initializeApp() but it lets me use 8.4.0 now, with the slick new emulator UI.
Hope that's useful for someone.
@natethegreat44 thanks! That really helps point me to the solution. This is related to a recent change I made: https://github.com/firebase/firebase-tools/pull/2213
Fixing in #2291
In general nobody should be using initializeApp(functions.config().firebase) anymore. The plain initializeApp() is preferred.
@natethegreat44 thanks! This solved it for me too
Most helpful comment
Also present in 8.4.0. It was a regression in 8.3.0, and it's not fixed yet :( The solution is to downgrade to 8.2.0