Vite failing to load main.jsx file in React project

35 views Asked by At

I'm encountering an issue when trying to run a Vite React application. The development server fails to load the `main.jsx` file, which is the entry point of my React applicatio
he is the main.jsx code :

import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)

and here is the index code :

<body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>

and here is the error i got :

00:41:51 [vite] Pre-transform error: Failed to load url /src/main.jsx (resolved id: C:/Users/HP/OneDrive/Desktop/ChatApp/chat/src/main.jsx). Does the file exist?
file:///C:/Users/HP/OneDrive/Desktop/ChatApp/chat/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:52662
                        JSON.stringify(output.imports)),
                                              ^

TypeError: Cannot read properties of undefined (reading 'imports')  
    at file:///C:/Users/HP/OneDrive/Desktop/ChatApp/chat/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:52662:47
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)00:41:51 [vite] Pre-transform error: Failed to load url /src/main.jsx (resolved id: C:/Users/HP/OneDrive/Desktop/ChatApp/chat/src/main.jsx). Does the file exist?
file:///C:/Users/HP/OneDrive/Desktop/ChatApp/chat/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:52662
                        JSON.stringify(output.imports)),
                                              ^

TypeError: Cannot read properties of undefined (reading 'imports')  
    at file:///C:/Users/HP/OneDrive/Desktop/ChatApp/chat/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:52662:47
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0

There are 0 answers