简体   繁体   English

Webpack < 5 使用 firebase 管理员时出现问题

[英]Webpack < 5 Issue when using firebase admin

When i want to use the firebase admin SDK using the following code当我想使用以下代码使用 firebase admin SDK 时

import * as admin from 'firebase-admin';
var serviceAccount = require("../services/serviceAccountKey.json");
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://voter-60a9f-default-rtdb.europe-west1.firebasedatabase.app"
});

I get this error我收到这个错误

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

This is just one of many.这只是其中之一。 I also have this:我也有这个:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }

and so on....等等....

I tried reinstalling the Node modules but no luck.我尝试重新安装 Node 模块,但没有成功。 I also dont understand where i should add that fallback they suggest.我也不明白我应该在哪里添加他们建议的回退。 And if i would find it, do i need to add this for all the node modules?如果我能找到它,我是否需要为所有节点模块添加它?

Thanks!谢谢!

I faced this same error what u can do is go to node_modules/react-scripts/config/webpack-config.js and make these changes我遇到了同样的错误你可以做的是 go 到 node_modules/react-scripts/config/webpack-config.js 并进行这些更改

resolve: {
  modules: ...,
  extensions: ...,
  alias: {...}, fallback: {
    "fs": false,
    "tls": false,
    "net": false,
    "path": false,
    "zlib": false,
    "http": false,
    "https": false,
    "stream": false,
    "crypto": false,
    "crypto-browserify": false,
    "url": require.resolve("url"),
    "os": false,
    "os-browserify": false,
    "querystring": false,
    "buffer": false,
    "constants": false,
    "child_process": false
  },
  plugins: [...]
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 firebase_admin 上使用“where”查询时无法过滤数据 - cannot filter data when using `where` query on firebase_admin Python Firebase 问题没有名为 firebase_admin 的模块 - Python Firebase issue No module named firebase_admin 如何使用Firebase admin查询Firebase用户? - How to query Firebase users using Firebase admin? 将 Webpack 与 Firebase 消息服务工作者一起使用 - Using Webpack with Firebase Messaging service worker 如何使用 firebase admin SDK 访问 admin firestore? - How to access admin firestore using firebase admin SDK? Firebase 在通过 GitHub 操作部署时使用旧的 webpack 包进行托管 - Firebase hosting using Old webpack bundle when deployed via GitHub Actions 无法在 node.js admin sdk 中使用 firebase documentId()(firebase-admin npm package 语法问题) - Unable to use firebase documentId() in node js admin sdk (firebase-admin npm package grammar issue) 设置 webpack.config.js 以运行 firebase admin sdk 的正确方法是什么 - What is the correct way to setup webpack.config.js to run the firebase admin sdk 将 nextjs monorepo 项目与 lerna 一起使用时,无法解析 firebase-admin/lib 中的“fs” - Can't resolve 'fs' in firebase-admin/lib' when using nextjs monorepo project with lerna 使用 firebase-admin 发送主题通知 - Sending topic notifications using firebase-admin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM