迁移到VITE:未捕获类型错误:无法读取未定义的属性
出于在开发环境中的性能原因,我正在尝试将一个大型应用程序从create-react-app
迁移到Vite.js。
我遵循了以下指南:https://phelipetls.github.io/posts/migrating-from-cra-to-vite/
这是详细错误:
Uncaught TypeError: Cannot read property 'attrs' of undefined
at node_modules/styled-bootstrap-grid/dist/components/Container/Container.js (Container.js:68)
at __require2 (chunk-VZ7BJMYF.js?v=f5540ad4:17)
at node_modules/styled-bootstrap-grid/dist/components/Container/index.js (index.js:27)
at __require2 (chunk-VZ7BJMYF.js?v=f5540ad4:17)
at node_modules/styled-bootstrap-grid/dist/index.js (index.js:53)
at __require2 (chunk-VZ7BJMYF.js?v=f5540ad4:17)
at dep:styled-bootstrap-grid:1
node_modules/styled-bootstrap-grid/dist/components/Container/Container.js @ Container.js:68
__require2 @ chunk-VZ7BJMYF.js?v=f5540ad4:17
node_modules/styled-bootstrap-grid/dist/components/Container/index.js @ index.js:27
__require2 @ chunk-VZ7BJMYF.js?v=f5540ad4:17
node_modules/styled-bootstrap-grid/dist/index.js @ index.js:53
__require2 @ chunk-VZ7BJMYF.js?v=f5540ad4:17
(anonymous) @ dep:styled-bootstrap-grid:1
injector.js:239
我如何调试它?有什么建议吗?
提前谢谢!
M
解决方案
这似乎是CommonJS语法错误,因为Vite不支持CommonJS语法。您可以尝试使用Vite插件vite-plugin-commonjs
btw,
https://github.com/originjs/webpack-to-vite
这是我在转换旧项目时搜索错误消息时发现的GitHub项目。它列出了一些转换项和错误修复方法。它甚至可以一键将旧项目转换为VITE项目。太棒了,我推荐它!
相关文章