【问题标题】:Can't resolve 'fs' in firebase-admin/lib' when using nextjs monorepo project with lerna将 nextjs monorepo 项目与 lerna 一起使用时,无法解析 firebase-admin/lib 中的“fs”
【发布时间】:2021-08-12 12:49:34
【问题描述】:

我有一个 Lerna MonoRepo 项目设置。

喜欢

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.

当我尝试构建下一个 js 应用时,会出现以下错误。

块引用 ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'root-project/node_modules/firebase-admin/lib'。

【问题讨论】:

  • 确保只在服务器专用代码中使用firebase-admin(例如getStaticPropsgetServerSideProps、API 路由)。

标签: reactjs next.js firebase-admin monorepo lerna


【解决方案1】:

firebase-admin 包应该在 Node 环境中运行,而不是在浏览器项目中。 'fs' 是一个内置的 Nodejs 包。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-07
    • 2018-12-03
    • 2021-08-01
    • 1970-01-01
    • 2020-08-16
    • 2017-07-29
    • 2018-12-16
    • 2020-07-14
    相关资源
    最近更新 更多