paritosh raj
paritosh raj

Reputation: 161

Can't resolve 'fs' in firebase-admin/lib' when using nextjs monorepo project with lerna

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'.

Upvotes: 6

Views: 3486

Answers (2)

imre Boersma
imre Boersma

Reputation: 81

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

Upvotes: 1

vijayst
vijayst

Reputation: 21846

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

Upvotes: 9

Related Questions