Emulator shell issue: TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received ''
[REQUIRED] Environment info
**firebase-tools: 6.10.0
**Platform: macOS 10.14.4
[REQUIRED] Test case
simply run npm run shell
[REQUIRED] Steps to reproduce
simply run npm run shell
[REQUIRED] Expected behavior
show the firebase shell
[REQUIRED] Actual behavior
throws the following error:
[debug] [2019-05-20T14:27:37.728Z] ----------------------------------------------------------------------
[debug] [2019-05-20T14:27:37.730Z] Command: /usr/local/Cellar/node/12.1.0/bin/node /usr/local/bin/firebase functions:shell
[debug] [2019-05-20T14:27:37.730Z] CLI Version: 6.10.0
[debug] [2019-05-20T14:27:37.730Z] Platform: darwin
[debug] [2019-05-20T14:27:37.730Z] Node Version: v12.1.0
[debug] [2019-05-20T14:27:37.731Z] Time: Mon May 20 2019 10:27:37 GMT-0400 (Eastern Daylight Time)
[debug] [2019-05-20T14:27:37.731Z] ----------------------------------------------------------------------
[debug]
[debug] [2019-05-20T14:27:37.741Z] > 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"]
[debug] [2019-05-20T14:27:37.741Z] > authorizing via signed-in user
[debug] [2019-05-20T14:27:37.741Z] [iam] checking project XXXXX for permissions ["firebase.projects.get"]
[debug] [2019-05-20T14:27:37.743Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projectsXXXXX:testIamPermissions
[debug] [2019-05-20T14:27:37.981Z] <<< HTTP RESPONSE 200
[warn] ⚠ Your requested "node" version "8" doesn't match your global version "12"
[debug] [2019-05-20T14:27:37.992Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/XXXXX
[debug] [2019-05-20T14:27:38.206Z] <<< HTTP RESPONSE 200
[debug] [2019-05-20T14:27:38.208Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/850974975708:getServerAppConfig
[debug] [2019-05-20T14:27:38.335Z] <<< HTTP RESPONSE 200
[info] ✔ functions: Emulator started at http://localhost:5001
[debug] [2019-05-20T14:27:38.342Z] [functions] Watching "/firebase-project/functions" for Cloud Functions...
[debug] [2019-05-20T14:27:38.603Z] DEBUG: Functions runtime initialized.
[debug] [2019-05-20T14:27:38.603Z] DEBUG: Disabled runtime features: {"functions_config_helper":true,"network_filtering":true,"timeout":true,"memory_limiting":true,"protect_env":true,"admin_stubs":true}
[warn] ⚠ TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received ''
at Module.require (internal/modules/cjs/loader.js:661:11)
at require (internal/modules/cjs/helpers.js:16:16)
at InitializeFirebaseAdminStubs (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:231:18)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:451:9
at Generator.next (<anonymous>)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:7:71
at new Promise (<anonymous>)
at __awaiter (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:3:12)
at main (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:421:12)
at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:511:5)
[warn] ⚠ Your function was killed because it raised an unhandled error.
This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.
Hi, could you share a minimal example of the code you're trying to load which causes this error?
I also see you're running the shell using Node 12. Can you try running this on Node 8 as well?
@abeisgoat i tried the following code:
import * as admin from 'firebase-admin'
import * as functions from 'firebase-functions'
try {
const serviceAccount = require('../XXXXXX.json')
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://XXXXXXX.firebaseio.com"
})
admin.firestore().settings({ timestampsInSnapshots: true })
} catch (err) {
// DO NOTHING
}
export const test = functions.https.onCall(async (data, context) => {
return "Hello"
})
@bkendall running it with Node 8 doesn't solves the problem but it throws a different error
[debug] [2019-05-20T18:28:12.642Z] ----------------------------------------------------------------------
[debug] [2019-05-20T18:28:12.644Z] Command: /usr/local/Cellar/node@8/8.16.0/bin/node /usr/local/bin/firebase functions:shell
[debug] [2019-05-20T18:28:12.644Z] CLI Version: 6.10.0
[debug] [2019-05-20T18:28:12.644Z] Platform: darwin
[debug] [2019-05-20T18:28:12.644Z] Node Version: v8.16.0
[debug] [2019-05-20T18:28:12.645Z] Time: Mon May 20 2019 14:28:12 GMT-0400 (EDT)
[debug] [2019-05-20T18:28:12.645Z] ----------------------------------------------------------------------
[debug]
[debug] [2019-05-20T18:28:12.654Z] > 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"]
[debug] [2019-05-20T18:28:12.654Z] > authorizing via signed-in user
[debug] [2019-05-20T18:28:12.654Z] [iam] checking project XXXXX for permissions ["firebase.projects.get"]
[debug] [2019-05-20T18:28:12.656Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/XXXXXX:testIamPermissions
[debug] [2019-05-20T18:28:12.929Z] <<< HTTP RESPONSE 200
[debug] [2019-05-20T18:28:12.939Z] [functions] Using node@8 from host.
[debug] [2019-05-20T18:28:12.939Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/XXXXXX
[debug] [2019-05-20T18:28:13.205Z] <<< HTTP RESPONSE 200
[debug] [2019-05-20T18:28:13.206Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/XXXXXXXXXXX:getServerAppConfig
[debug] [2019-05-20T18:28:13.394Z] <<< HTTP RESPONSE 200
[info] ✔ functions: Emulator started at http://localhost:5001
[debug] [2019-05-20T18:28:13.402Z] [functions] Watching "XXXXXXXX/functions" for Cloud Functions...
[debug] [2019-05-20T18:28:13.747Z] DEBUG: Functions runtime initialized.
[debug] [2019-05-20T18:28:13.747Z] DEBUG: Disabled runtime features: {"functions_config_helper":true,"network_filtering":true,"timeout":true,"memory_limiting":true,"protect_env":true,"admin_stubs":true}
[warn] ⚠ AssertionError [ERR_ASSERTION]: missing path
at Module.require (module.js:595:3)
at require (internal/module.js:11:18)
at InitializeFirebaseAdminStubs (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:231:18)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:451:9
at Generator.next (<anonymous>)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:7:71
at new Promise (<anonymous>)
at __awaiter (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:3:12)
at main (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:421:12)
at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:511:5)
[warn] ⚠ Your function was killed because it raised an unhandled error.
Thanks for the repro, I'll take a look and get back to you!
The errors you're experiencing in both versions are the same, the message just changed between Node versions.
In both situations the shell is failing to resolve the grpc module on functionsEmulatorRuntime.ts#389
This module specifically is prone to having issues, can you go to your functions directory and run...
node -e "console.log(require.resolve('grpc'))"
Let me know how it goes! thanks!
@abeisgoat thank you for having a look at the issue. I just updated the firebase-admin lib to 7.4.0 and the emulator run properly.
Hi,
Using firebase-tools 6.10.0, I had just upgraded firebase-admin to 8.0.0 and got what looks like pretty much the same error when starting the emulator. The work-around for me was to go into functions dir and npm install --save grpc. Then the emulator starts ok.
Stack traces below for reference:
emulator fails to start:
⚠ TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received ''
at Module.require (internal/modules/cjs/loader.js:634:11)
at require (internal/modules/cjs/helpers.js:22:18)
at InitializeFirebaseAdminStubs (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:231:18)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:451:9
at Generator.next (<anonymous>)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:7:71
at new Promise (<anonymous>)
at __awaiter (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:3:12)
at main (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:421:12)
at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:511:5)
⚠ Your function was killed because it raised an unhandled error.
Checking for grpc
If I go into functions and node -e "console.log(require.resolve('grpc'))" it looks like it cannot be found:
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'grpc'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.resolve (internal/modules/cjs/helpers.js:32:19)
at [eval]:1:21
at Script.runInThisContext (vm.js:96:20)
at Object.runInThisContext (vm.js:303:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at evalScript (internal/bootstrap/node.js:587:27)
at startup (internal/bootstrap/node.js:265:9)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Once grpc is installed these errors go away.
Like @tmcf said. Im facing the same exact problem, moved from firebase-tools 6.10.0 to 8.0.0 and got the same error. I also got the same result when running node -e "console.log(require.resolve('grpc'))"
@tmcf as @v3n3 said above I just downgraded to the previous version yarn add [email protected] to get the emulator working in the meanwhile.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received '', i am having this error while working in express.js, can you help me
@ThatRandomGuy09 Would you mind opening a new issue so we can take a look? Thank you!
@ThatRandomGuy09 Would you mind opening a new issue so we can take a look? Thank you!
SURE