迁移到VITE:未捕获类型错误:无法读取未定义的属性 [英] Migrating to Vite: Uncaught TypeError: Cannot read property 'attrs' of undefined

查看:25
本文介绍了迁移到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项目。太棒了,我推荐它!

这篇关于迁移到VITE:未捕获类型错误:无法读取未定义的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆