question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Production serverless build importing Firestore fails while including 'google/protobuf/api.proto'

See original GitHub issue

Bug report

Describe the bug

When using import "firebase/firestore" on a page with target: "serverless" in next.config.js, next build fails with the following error:

> Build error occurred
Error: ENOENT: no such file or directory, open 'google/protobuf/api.proto'

To Reproduce

  1. Clone https://github.com/WestonThayer/bug-nextjs-firestore-grpc
  2. npm install
  3. npm run build

Expected behavior

The production build should succeed. It used to work in next@8.1.0.

System information

  • OS: macOS 10.14.6 (Mojave)
  • Version of Next.js: 9.3.4
  • Version of Node.js: v12.15.0
  • Version of Firebase: 7.14.0

Additional context

  • The build will succeed if you remove target: "serverless" from next.config.js
  • Strangely, next build succeeds in the Zeit NOW environment. I see NOW is also using Node v12.15.0, so scratching my head as to what’s different

Seems like this is something that Next tried to get working in the past:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
GuillaumeBeckercommented, Apr 17, 2020

@Timer thx for the quick response. I will try to see with serverless-next.js then. When you mentioned to use the new target, do you mean target: 'experimental-serverless-trace' ?

2reactions
Timercommented, Apr 14, 2020

Thanks for this excellent feedback. We’ll take it into account and rework the docs around this.

Regarding your questions above, deployments to ZEIT Now still use our builders (via zero config). Meaning @now/next still runs the show!

This is the code that forces the target: https://github.com/zeit/now/blob/master/packages/now-next/src/create-serverless-config.ts

This is the code that wraps the build output for ZEIT Now: https://github.com/zeit/now/blob/master/packages/now-next/src/index.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Production serverless build importing Firestore fails while ...
When using import "firebase/firestore" on a page with target: "serverless" in next.config.js , next build fails with the following error:.
Read more >
Unable to build NextJS app locally when using Firestore
I'm building a web app and am fetching data from the Firestore both on the client and on the server with getStaticProps and...
Read more >
Top 10 Serverless Deployment Errors (and How to Fix Them)
The cause: This error is caused when creating a API Gateway resource with a method (GET, PUT, POST, etc.) but not connecting that...
Read more >
Cloud Functions for Firebase - Google
Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features...
Read more >
Importing Data to a Firestore Database
In this lab you will upload existing data (a CSV file) to a Firestore serverless database in the cloud.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found