Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vite React Project .env variable not changing value

Tags:

reactjs

vite

I'm doing a React project using Vite and I'm having a problem with my .env variable. Currently it is set like this

VITE_API_URL=http://localhost:8080

and I access it using: import.meta.env.VITE_API_URL

But recently, I need to change the value of this variable but I see that the old value is still being used regardless of what I do. I tried resetting the project, computer, using npm cache clean --force and deleting the .vite folder. Any suggestions?

like image 397
Rolando Avatar asked Jul 30 '26 20:07

Rolando


1 Answers

Something with the terminal is caching those .env values, I don't know if that's technically what's going on. But killing the terminal instance and running the process again from a new terminal should bring in the latest values.

like image 194
Benjamin Musil Avatar answered Aug 02 '26 09:08

Benjamin Musil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!