[英]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.