迁移到 Vite:未捕获的 TypeError:无法读取未定义的属性“attrs”
2021-06-01
3560
出于开发环境中性能的原因,我正在尝试将一个大型应用程序从
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
1个回答
似乎是 CommonJS 语法错误,因为 vite 不支持 CommonJS 语法,你可以尝试使用 vite 插件
vite-plugin-commonjs
BTW,
https://github.com/originjs/webpack-to-vite
这是我在转换旧项目时搜索错误信息时发现的一个 github 项目,列出了一些转换项和错误修复方法,甚至可以一键将旧项目转换为 vite 项目,很棒,推荐!
Chieffo
2021-09-01