vitejs / vite-plugin-react

The all-in-one Vite plugin for React projects.
MIT License
605 stars 111 forks source link

When i run npm run dev on my react project i get an error that has happened in a similar manner to astro #365

Closed tolubori07 closed 1 month ago

tolubori07 commented 1 month ago

Describe the bug

I am running npm run dev to start my react server, however i get this error all the time [vite] Internal server error: Cannot redefine property: File Plugin: vite:react-babel File: /Users/moshoodbello/Coding/NEA/frontend/src/main.jsx at Function.defineProperty (<anonymous>) at Object.<anonymous> (/Users/moshoodbello/Coding/NEA/frontend/node_modules/@babel/core/lib/index.js:7:8) at Module._compile (node:internal/modules/cjs/loader:1241:14) at Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at Object.<anonymous> (/Users/moshoodbello/Coding/NEA/frontend/node_modules/@babel/core/lib/config/helpers/config-api.js:16:14) at Module._compile (node:internal/modules/cjs/loader:1241:14) Another thing that might be of help is that a similar problem occurred with astro, I would've assumed this was an issue with astro but it then happened to react so i assume that this might be a vite issue?

Reproduction

/

Steps to reproduce

I Run npm run dev

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 1.09 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.6.0 - ~/node_modules/.bin/node
    npm: 10.8.2 - /usr/local/bin/npm
    bun: 1.1.20 - ~/.bun/bin/bun
  Browsers:
    Chrome: 128.0.6613.138
    Safari: 17.6
  npmPackages:
    @vitejs/plugin-react: ^4.3.1 => 4.3.1 
    vite: ^5.4.0 => 5.4.0

Used Package Manager

npm

Logs

Plugin: vite:react-babel File: /Users/moshoodbello/Coding/NEA/frontend/src/main.jsx at Function.defineProperty () at Object. (/Users/moshoodbello/Coding/NEA/frontend/node_modules/@babel/core/lib/index.js:7:8) at Module._compile (node:internal/modules/cjs/loader:1241:14) at Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at Object. (/Users/moshoodbello/Coding/NEA/frontend/node_modules/@babel/core/lib/config/helpers/config-api.js:16:14) at Module._compile (node:internal/modules/cjs/loader:1241:14) vite:time 27.31ms /src/main.jsx +243ms vite:load 22.26ms [fs] /@vite/client +6ms vite:resolve 1.54ms @vite/env -> /Users/moshoodbello/Coding/NEA/frontend/node_modules/vite/dist/client/env.mjs +33ms vite:import-analysis 8.88ms [1 imports rewritten] node_modules/vite/dist/client/client.mjs +0ms vite:transform 13.29ms /@vite/client +0ms vite:time 38.32ms /@vite/client +16ms vite:load 2.80ms [fs] /node_modules/vite/dist/client/env.mjs +16ms vite:import-analysis 0.07ms [no imports] node_modules/vite/dist/client/env.mjs +3ms vite:transform 0.58ms /node_modules/vite/dist/client/env.mjs +2ms vite:import-analysis 0.85ms [0 imports rewritten] /@react-refresh +3ms vite:transform 39.91ms /@react-refresh +3ms vite:time 41.79ms /@react-refresh +6ms vite:cache [304] /node_modules/vite/dist/client/env.mjs +0ms vite:time 0.44ms /node_modules/vite/dist/client/env.mjs +11ms

Validations

hi-ogawa commented 1 month ago

This looks like an issue with Node 20.6.0 specifically

Can you try it again after updating node?