next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Error when building with firebase

Open billcastillo opened this issue 7 years ago • 8 comments

Running npm run build or deploying to now generates the error below I made a small repo here

To replicate issue:

  1. npm install
  2. npm run build

Additional notes:

  • npm run dev works fine, locally. I can't deploy due to error.
  • Removing target: 'serverless' removes the error on build but I can't deploy it without the serverless config
  • I am using rebase from @tylermcginnis
Failed to compile.

./node_modules/@firebase/database/dist/index.node.cjs.js
Module not found: Can't resolve 'request' in '/Users/next -firebase/node_modules/@firebase/database/dist'

> Build error occurred
Error: > Build failed because of webpack errors
    at Object.build [as default] (/Users/next-firebase/node_modules/next/dist/build/index.js:99:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! create-next-example-app@ build: `next build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the create-next-example-app@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

billcastillo avatar Mar 14 '19 09:03 billcastillo

I'm also having this same problem with the Firebase Hosting example. Would love to hear your solution to this problem if you found one.

eddiebeazer avatar Mar 14 '19 14:03 eddiebeazer

It looks like this import in index.js is causing the deployment problem:

import { database } from 'firebase';

The file doesn't seem to be using this import at all, so you can safely remove it. I can see you are importing individual firebase packages correctly via the rebase.js file.

Without this line, the deployment is successful, but the app still doesn't work. It's probably related to this: https://spectrum.chat/next-js/general/import-firebase-firestore-causing-error-on-the-client~5a0570ff-1ccc-4abd-b23a-01272344154f

kheruc avatar Mar 14 '19 14:03 kheruc

We're adding support for Firebase in serverless soon, we'll post here when we have an update!

Timer avatar Jun 14 '19 15:06 Timer

@Timer Is there a workaround in the mean time? Thanks!

kjkurtz avatar Jun 18 '19 14:06 kjkurtz

@Timer hey sorry to bodder you Joe, is there any fix encounter soon? (all good on dev server, but still cannot build using firebase even old versions). Many thanks

scemii avatar Jul 02 '19 22:07 scemii

@scemii hey! We finalized some changes needed, but we're focusing on releasing Next 9 right now. 🙏

This is one of our high priority items right after 9.0 ships!

Timer avatar Jul 03 '19 00:07 Timer

@Timer Hi, thank you for the support ! Do you have any ETA for this ?

michel-p avatar Jul 13 '19 08:07 michel-p

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

balazsorban44 avatar Jan 31 '22 09:01 balazsorban44