Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: "functions is not defined" when running firebase deploy #187

Open
slifty opened this issue Oct 10, 2022 · 2 comments
Open

bug: "functions is not defined" when running firebase deploy #187

slifty opened this issue Oct 10, 2022 · 2 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@slifty
Copy link

slifty commented Oct 10, 2022

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

  1. Follow the basic setup recommended by the project
  2. Populate functions/index.js with the CLI output for the ssrServer
  3. Attempt to build / deploy
  4. 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

@slifty slifty added the bug Something isn't working label Oct 10, 2022
@slifty slifty changed the title bug: bug: "functions is not defined" when running firebase deploy Oct 10, 2022
@slifty
Copy link
Author

slifty commented Oct 10, 2022

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.

@jthegedus
Copy link
Owner

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.

@jthegedus jthegedus added the documentation Improvements or additions to documentation label Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants