vitejs/vite-plugin-react

Uncaught Error:@vitejs/plugin-react can't detect preamble. Something is wrong.

Closed this issue · 3 comments

Describe the bug

  1. Create a front-end project using npm create vite@latest my-vite-react-ts-app -- --template react-ts.
  2. After startup, an error is reported: Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. See #11.

Reproduction

npm create vite@latest --template react-ts

Steps to reproduce

  1. Run the following command to create a new Vite project:
npm create vite@latest my-vite-react-ts-app -- --template react-ts
  1. Enter the project directory:
cd my-vite-react-ts-app
  1. Install dependencies:
yarn
  1. Start the development server:
yarn dev

After startup, an error is reported:

image

Later, it was found that the browser version is related.

There is an error with chrome 95.0.4638.69.

When switching to chrome version 112.0.5615.138 (official version) (64-bit), it can run normally.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700
    Memory: 1.33 GB / 15.70 GB
  Binaries:
    Node: 18.20.4 - C:\Program Files\nodejs\node.EXE 
    Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD 
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD    
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (127.0.2651.86)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @vitejs/plugin-react: ^4.3.1 => 4.3.1
    vite: ^5.4.1 => 5.4.8

Used Package Manager

yarn

Logs

No response

Validations

I guess you see the following error as well.

TypeError: Cannot read property 'forEach' of undefined

This error happens when you are using an old react devtools extension: facebook/react#25019

Thanks for looking into it @sapphi-red!
We don't encourage looking such an old browser for dev anyway