Reputation: 1862
I have 2 HTTP functions. When deployed to cloud it is working good. But for development, when I try to serve them locally with
firebase serve --only functions
I am getting this error,
ERROR: Function load error: Code could not be loaded.
ERROR: Does the file exists? Is there a syntax error in your code?
ERROR: Detailed stack trace: /home/saiy2k/projects/ionic/grcloud/functions/node_modules/@google-cloud/common/src/util.js:545
throw util.missingProjectIdError;
^
Error: Sorry, we cannot connect to Google Cloud Services without a project ID. You may specify one with an environment variable named "GCLOUD_PROJECT". See https://googlecloudplatform.github.io/google-cloud-node/#//docs/guides/authentication for a detailed guide on creating an authenticated connection.
at Object.<anonymous> (/home/saiy2k/projects/ionic/grcloud/functions/node_modules/@google-cloud/common/src/util.js:54:29)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/saiy2k/projects/ionic/grcloud/functions/node_modules/@google-cloud/common/src/service.js:30:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/saiy2k/projects/ionic/grcloud/functions/node_modules/@google-cloud/common/src/grpc-service.js:38:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
⚠ functions: Failed to emulate handlePayment
⚠ functions: Failed to emulate testHTTPListener
i functions: No HTTPS functions emulated. Support for other function types are coming soon.
Tried setting a env variable like this,
firebase functions:config:set GCLOUD_PROJECT="gr-staging"
But got this error: Error: Invalid config name GCLOUD_PROJECT, cannot use upper case.
Had a look at this page: https://firebase.google.com/docs/functions/local-emulator Any else to take care of, to serve the HTTP functions locally?
Firebase CLI: v3.10.1 My Package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"@google-cloud/storage": "^0.4.0",
"child-process-promise": "^2.2.0",
"firebase-admin": "~4.2.1",
"firebase-functions": "^0.5.9",
"mkdirp": "^0.5.1",
"mkdirp-promise": "^4.0.0",
"moment": "^2.18.1",
"request": "^2.81.0",
"request-promise": "^4.2.1",
"typescript": "^2.4.2"
},
"private": true,
"devDependencies": {
"ts-loader": "^2.3.2",
"webpack-node-externals": "^1.6.0"
}
}
Upvotes: 1
Views: 489
Reputation: 4034
For what its worth, and by no means is this a good solution, but it works.
Commenting out the throw
in /home/saiy2k/projects/ionic/grcloud/functions/node_modules/@google-cloud/common/src/util.js
on line 545 that is causing the error causes no ill effect to the emulator that I can gather.
All of the objects that check function is receiving are either undefined or null in my instance so without checking back up the stack about why this should be i'm happy with this hack to get me back on the road!
Upvotes: 1