reactjstypescriptvite

Uncaught SyntaxError: Export 'import_react3' is not defined in module (at chunk-ALR5B6M7.js?v=aa4e0109:17143:3)


I have a project created with create-react-app with Typescript. And I am using yarn 3.3.0 as the package manager.

Now I am trying to shift from cras webpack to vite. I have bootstrapped a project with the yarn create vite command. And simply copy and paste the components from previous project to the new one.

When I run on the command line yarn tsc I am facing no error.

Also running yarn dev is okay in the terminal and the server starts successfully.

However, in the browser I am facing an weird error on the terminal which says:

Uncaught SyntaxError: Export 'import_react3' is not defined in module (at chunk-ALR5B6M7.js?v=aa4e0109:17143:3)

enter image description here


Solution

  • Apparently, since I am using Material UI I need to install @emotion/react and @emotion/styled as well.

    npm i @emotion/react @emotion/styled
    
    or
    
    yarn add @emotion/react @emotion/styled