bug: "functions is not defined" when running `firebase deploy`
slifty opened this issue · comments
Describe the Bug
The default code output to the CLI seems to assume that functions
is defined -- I don't have any server side functions / I was starting with a vanilla sveltekit application and my /functions/index.js
only exists for this adapter.
When I run firebase deploy
I get the following error:
i deploying functions, hosting
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔ functions: required API cloudfunctions.googleapis.com is enabled
✔ artifactregistry: required API artifactregistry.googleapis.com is enabled
✔ functions: required API cloudbuild.googleapis.com is enabled
i functions: preparing codebase default for deployment
Error: Error occurred while parsing your function triggers.
ReferenceError: functions is not defined
at Object.<anonymous> (/Users/slifty/Maestral/Code/thefemalequotient/speaker-equity-assessor/functions/index.js:3:21)
at Module._compile (node:internal/modules/cjs/loader:1119:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)
at loadModule (/Users/slifty/.nvm/versions/node/v18.9.0/lib/node_modules/firebase-tools/lib/deploy/functions/runtimes/node/triggerParser.js:10:16)
at /Users/slifty/.nvm/versions/node/v18.9.0/lib/node_modules/firebase-tools/lib/deploy/functions/runtimes/node/triggerParser.js:34:21
at Object.<anonymous> (/Users/slifty/.nvm/versions/node/v18.9.0/lib/node_modules/firebase-tools/lib/deploy/functions/runtimes/node/triggerParser.js:72:3)
This is unsurprising since I see the generated code references functions.logger.info
in a few places.
Steps to Reproduce
- Follow the basic setup recommended by the project
- Populate
functions/index.js
with the CLI output for the ssrServer - Attempt to build / deploy
- See the error
Expected Behaviour
I would expect either the documentation or the CLI output to account for the case where functions
is not defined already in index.js
svelte-adapter-firebase version
0.14.4
sveltejs/kit version
1.0.0-next.488
I see the issue now -- the README assumes that I not just run firebase init
but that I explicitly set up functions
<-- I had NOT done that (though I had run firebase init so thought I was ok!).
Maybe the solution here would just be to update the README to be clear what aspects of the firebase init need to have been set up.
Yeah, sorry about that. The docs are complex and should probably be their own interactive site at this point. Thanks for the suggestion, docs will be a focus after Kit v1.0 in the new year.