How to solve the following error ?
Uncaught ReferenceError: process is not defined
Enter fullscreen mode
Exit fulls...
For further actions, you may consider blocking this person and/or reporting abuse
You, sir, are a lifesaver! (Also created an account just to say that.)
you are a genius
i'd created this account just to tell you: u r my f*cking hero
Seems like "process.env" is removed, have to use "import.meta.env" instead.
So instead of process.env.VITE_SOME_KEY -> import.meta.env.VITE_SOME_KEY
Read more here - vitejs.dev/guide/env-and-mode.html
I suspect this is the actual solution, but I can't say as I understand why VITE deviates from the standard approach.
Graciass geniooooooooooooooooooooooooo!!!
on my side, loadEnv was throwing an error then i revised my code s below. things worked perfectly. thanks for the clue i was totally lost
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import dotenv from 'dotenv';
dotenv.config(); // Load environment variables from .env
// vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
define: {
'process.env.REACT_APP_BASE_URL': JSON.stringify(process.env.REACT_APP_BASE_URL),
},
plugins: [react()],
};
});
Just do it the Vite way and forget all of this!
Done.
Thank you, it was really helpful!
Thank you for writing this!
worked on local but fails when deploying the project to vercel. any help?
Thanks a lot
Thank you so much!!! ❤️
wow, you saved my time bruh
Thanks a lot, it worked like a charm.
Best docs i have read till date
very helpful
Thank you Bro!
That helped me!!!
Thanks a lot!
You help me too much!
i'd also created this account just to tell you: u r my f*cking hero
I've been looking for this shit all over the internet and you're the one who saved me, thanks bro
Thank you so much