创建 React App 生产构建运行时错误:无法读取未定义的属性“调用" [英] Create React App production build runtime error: Cannot read property 'call' of undefined
问题描述
我有一个 CRA 项目,当我在开发中使用 react-scripts start
时运行良好.但是一旦我构建 react-scripts build
然后提供这些文件,我就会收到这个错误未捕获的类型错误:无法读取未定义的属性调用"
I have a CRA project that runs fine when i use react-scripts start
in development. But once I build react-scripts build
and then serve these files, I get this error
Uncaught TypeError: Cannot read property 'call' of undefined
我没有任何自定义的 webpack 配置.我尝试对大量源代码进行注释,但在尝试提供构建文件时仍然出现此错误.
I dont have any custom webpack config. I've tried to comment large areas of source code, and I still get this error trying to serve the build files.
感谢您的帮助!
推荐答案
我找到了这个答案,它解决了这个问题.https://stackoverflow.com/a/58628185/5231665
我只需要将它添加到 react-scripts
webpack.config.js
I found this answer, and it solved the issue.
https://stackoverflow.com/a/58628185/5231665
I just had to add this to the react-scripts
webpack.config.js
optimization: {
sideEffects: false,// <----- in production defaults to true if left blank
}
这篇关于创建 React App 生产构建运行时错误:无法读取未定义的属性“调用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!