Vite is probably changing my import path. What should I do?

21 views Asked by At

I keep getting this error when I'm running my front-end server (5173, vite) , and my backend server which is synchronized with my front. This is how I import my file in one my my reducers in reducer:

import { toyService } from "./../../services/toy.service.js"

It is the right path. Whenever I'm running both of my servers, my browser shows me this: 'Uncaught

ReferenceError: Cannot access 'toyService' before initialization
    at toy.reducer.js:24:15'

(A line using a function from toyService). The same happens with the other reducer although the import path is correct. I have not modified any detail in the configuration Vite file and it used to work just fine. When I looked at how my browser is trying to reach this file using the Sources at the devtools, I saw this:

'import { toyService } from "/src/services/toy.service.js"

Does anybody have any idea what would cause such error? It is worth mentioning I use MongoDB to get at modify data at the backend.

So far I have consulted with friends, ChatGPT, tried to find anything about such error on Google.. nothing.

0

There are 0 answers