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.)
i'd created this account just to tell you: u r my f*cking hero
you are a genius
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!!!
Just do it the Vite way and forget all of this!
Done.
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()],
};
});
Thank you for writing this!
Thanks a lot, it worked like a charm.
wow, you saved my time bruh
Thank you so much!!! ❤️
Thanks a lot
worked on local but fails when deploying the project to vercel. any help?
Best docs i have read till date
Thank you so much
very helpful
Thanks a lot!
You help me too much!
Thank you Bro!
That helped me!!!
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