javascript - Webpack 包错误:无法读取未定义的属性
问题描述
我的网络应用程序使用 Webpack 5.45.1 作为模块捆绑器和唯一的库 - ethereum web3.js
1.4.0。
// webpack configuration file
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const path = require('path');
module.exports = {
mode: 'development',
output: {
path: path.resolve(__dirname, 'dist/dev'),
filename: '[name].bundle.js',
},
entry: {
index: './src/index.js'
},
module: {
rules: [
{
test: /\.css$/,
use: ['css-loader'],
}
]
},
plugins: [
new NodePolyfillPlugin()
]
}
入口点包含一个语句:import Web3 from 'web3';
使用浏览器执行生成的包会出现以下错误:
assertion_error.js:486 Uncaught TypeError: Cannot read property 'custom' of undefined
at eval (assertion_error.js:486)
at eval (assertion_error.js:500)
at Object../node_modules/assert/build/internal/assert/assertion_error.js (index.bundle.js:1063)
at __webpack_require__ (index.bundle.js:6721)
at eval (assert.js:38)
at Object../node_modules/assert/build/assert.js (index.bundle.js:1052)
at __webpack_require__ (index.bundle.js:6721)
at eval (index.js:3)
at Object../node_modules/console-browserify/index.js (index.bundle.js:1624)
at __webpack_require__ (index.bundle.js:6721)
我发现了,undefined
是这个表达式的一个值:require('util/').inspect
.
任何人都可以提供有关如何修复它的提示吗?
解决方案
事实证明,在我的情况下,问题出在 中NodePolyfillPlugin
,它有一个与循环依赖相关的错误。我在github上打开了这个问题。
推荐阅读
- python-3.x - 我想知道这些代码之间的区别
- google-sheets - 我可以从导出 URL 指定下载的文件名吗?
- python-3.x - 我创建了一个条目小部件并将其放置在网格中,但它没有显示
- docusignapi - 无法在 Salesforce 移动应用程序/网站上完成 Doc 发送
- android - 如果满足某些条件,是否可以在没有网络的情况下使用 firebase 创建自动推送通知?
- spring-data-jpa - Spring Data Jpa @query 行为
- acumatica - Acumatica Mobile:无法将“System.Int32”类型的对象转换为“System.String”类型
- terminal - 白蚁终端铃声设置不起作用
- mysql - MySQL优化2个大表的连接
- batch-file - 如何使这个批处理文件响应 vbs 弹出窗口中给出的答案?