So when you run npm run start command, all .env.dev environment variables will be available through process.env.some_key and when you run npm run start-prod command, all .env.prod environment variables will be available through process.env.some_key only.
do we need to activate any .env file ?
like sometimes, i have to activate some env files in the bash shell like
source ./example.env
and if we create a file through
.env.prod
what package do we need to install ?
like
dotenv
?instead ofnpm-cmd
it is looking very complexand how to use
.env.prod
is it same like
process.env.prod.SOME_KEY
??There is no need of activating .env file. For .env.prod you can use the env-cmd npm package and use it as shown below:
So when you run
npm run start
command, all .env.dev environment variables will be available through process.env.some_key and when you runnpm run start-prod
command, all .env.prod environment variables will be available through process.env.some_key only.ok you left one point , please answer that too
i have asked, that if i have .env.dev file
and i have some key as
then how do i need to use it?
Do i need to use it as
or
you need to use process.env.SOME_KEY only. Also don't add spaces before and after the
=
sign in .env fileokay thankyou sir, i will definitely try this
so,
and importing it as
I think this is fine now
Yes, it looks fine