firebase-gcp-examples: Error in deploy
This example with erro in deploy
yarn build ✔ yarn serve ✔
i deploying functions, hosting i functions: ensuring necessary APIs are enabled… ✔ functions: all necessary APIs are enabled i functions: preparing . directory for uploading…
Error: Error occurred while parsing your function triggers.
Error: > Couldn’t find a pages directory. Please create one under the project root
at findPagesDir (/Users/robsonkades/Documents/myprojects/firebase-gcp-examples/functions-nextjs/node_modules/next/dist/lib/find-pages-dir.js:3:170)
at new DevServer (/Users/robsonkades/Documents/myprojects/firebase-gcp-examples/functions-nextjs/node_modules/next/dist/server/next-dev-server.js:1:2962)
at createServer (/Users/robsonkades/Documents/myprojects/firebase-gcp-examples/functions-nextjs/node_modules/next/dist/server/next.js:2:105)
at Object.<anonymous> (/Users/robsonkades/Documents/myprojects/firebase-gcp-examples/functions-nextjs/dist/server/index.js:22:31)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 30 (13 by maintainers)
Hi all, please see my new example which addressed many of the issues people had with the setup. I believe the structure will cause less confusion.
https://github.com/jthegedus/firebase-gcp-examples/tree/master/functions-nextjs
Lol, sorry about that.
I have the new emulator in this example, though the Next.js development server doesn’t run well on the local Cloud Function. I don’t think you will need to run the local emulator though as the
next devserver does most of what you need. The Cloud Function server is just a bridge between the two envs, not a fully working development setup.Given the drastically new example I will close this. If you find issues with the new setup please do raise new issues! Thanks
@robsonkades I changed
"deploy": "yarn firebase deploy --only functions,hosting"to
"deploy": "NODE_ENV=production yarn firebase deploy --only functions,hosting"and it worked
Is this repo public and could you share it? Would make debugging easier.
I’ve just gone back to using
npmas everyone has it whereas that is not the case foryarnunfortunately.I’ve got a completely reworked version of this which I will release this weekend. It simplifies the setup much more and leverages the latest Next.js features. Stay tuned.
Hi @robsonkades
firebase serveis problematic. I wouldn’t recommend using it. See my recommendations on the next.js repo example. I intend to update this example using the new emulator within the next 48 hours.Thanks for taking the time to report this here 💯
I got it to work with more banging my head against the package.json, I think it was a mistake to run npm run dev within the src/client folder to get a local version of it up and running. I migrated the package.json over to using npm and installed cross-env as well as install-peers to get past some of the errors I was seeing on build.
Google recently updated Cloud Functions to be private by default, so you are required to configure the IAM permissions on a per function level to allow access. I am planning an entire rewrite of my next.js guide in the coming weeks to address all these issues and more. Thanks for sharing your results here.
Alternative to @rscotten’s comment with NPM.