TypeError: Cannot read properties of null (reading ‘isCE’)
problem
控制台报错 TypeError: Cannot read properties of null (reading ‘isCE’)
reason
vue包重复
solution
修改vite.config.js
resolve: {
dedupe: [
'vue'
]
},
resolve.dedupe 用于防止项目中的依赖包被重复打包。
- dedupe(去重)确保项目中vue不会被多次加载,这对单例模式的库(如 Vue、React 等)尤为重要。
- 当项目中使用了多个依赖(或插件),这些依赖可能各自引用了同一个包(例如 vue)。
- 如果没有去重处理,可能会导致该包被加载多次,从而引起一些难以调试的问题,例如不同实例之间的数据不一致。