5

I have a Lerna MonoRepo project setup.

Like

root/
   lerna.json
   packgae.json
   package.lock.json
   packages/
       app1 - Create react app (with firebase sdk dependency)
       app2 - Next Js app (with firebase-admin dependency)
       components - shared react components.

when I try to build next js app then following error occurs.

Blockquote ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'root-project/node_modules/firebase-admin/lib'.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
paritosh raj
  • 151
  • 7
  • 2
    Make sure you only use `firebase-admin` in server-only code (e.g. `getStaticProps`, `getServerSideProps`, API routes). – juliomalves Aug 12 '21 at 15:16

2 Answers2

8

firebase-admin package is supposed to run in Node environments, not in browser projects. 'fs' is a built-in Nodejs package.

vijayst
  • 20,359
  • 18
  • 69
  • 113
0

Extending on vijayst's answer: You need to use the examples given for 'Web version 9' on de firebase docs. You cannot use firebase-admin on web. You can only use it server-side. You need to use the firebase package

imre Boersma
  • 71
  • 1
  • 9