Migrating to Vite: Uncaught TypeError: Cannot read property 'attrs' of undefined

Viewed 1685

I am trying to migrate a big app from create-react-app to Vite.js for reasons of performance in the dev environment.

I followed this guide: https://phelipetls.github.io/posts/migrating-from-cra-to-vite/

This is the detailed error:

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 

How could I debug this? Any tip?

Thanks in advance!

M

1 Answers

It seems a CommonJS syntax error because vite does not support CommonJS syntax. You can try to use vite plugin vite-plugin-commonjs

BTW,

https://github.com/originjs/webpack-to-vite

This is a github project that I found when I searched for error messages when I was converting an old project. It lists some conversion items and error repair methods. It can even convert an old project to a vite project with one click. It’s great, I recommend it!

Related