WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.22k forks source link

Cannot run React MUI - TypeError: can't access property "jsx", H is undefined #64562

Open wahabmirjan opened 3 months ago

wahabmirjan commented 3 months ago

Description

When I use the latest version of @wordpress/scripts, I receive a runtime error when trying to use React MUI. However, previous versions of @wordpress/scripts work just fine without causing a runtime error.

The details about the error and how to produce it are listed in the Step-by-step reproduction instructions section.

IMPORTANT NOTE: After further testing, I noticed that the error appears when I install any @wordpress/scripts that is version 28 (i.e., at the time of writing this bug, versions 28.0.0, 28.0.1, 28.0.2, 28.1.0, 28.2.0, 28.3.0, 28.4.0, and 28.5.0 did not work).

However, there is no run time error and the script runs without any problem, when installing either of the following versions: 26.12.0 and 27.9.0 (I only tested those versions).

Step-by-step reproduction instructions

  1. Install WordPress

  2. Install @wordpress/scripts

  3. Install react-mui accoring to thie instrauctions here https://mui.com/material-ui/getting-started/installation/ (note I only installed the default installation and Roboto font

    • npm install @mui/material @emotion/react @emotion/styled
    • npm install @fontsource/roboto
  4. Create a component as follows:

    
    import React from 'react'
    import { Typography } from '@mui/material'

const MyComponent = () => {

return (
    <div>
        <Typography>Hi</Typography>
    </div>
)

}

export default MyComponent



5. Run the code above, and I receive the following error: 
    `TypeError: Cannot read properties of undefined (reading 'jsx')`

### Screenshots, screen recording, code snippet

This is the error I receive:

![Screenshot from 2024-08-14 10-57-27](https://github.com/user-attachments/assets/8c7df8b1-6aac-4b6a-9619-12a82fe0ab05)

### Environment info

- WordPress Version 6.6,1
-  OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
- Browsers: Chrome and Firefox

### Please confirm that you have searched existing issues in the repo.

- [X] Yes

### Please confirm that you have tested with all plugins deactivated except Gutenberg.

- [X] Yes
vino4all commented 3 weeks ago

I'm also getting the same problem When I tried to use the https://wordpress.org/plugins/wp-event-solution/ plugin with Wordpress hosted on a Linux (ubuntu 24.04) server (Azure Virtual Machine).

Image

Any help is much appreciated.