#Environment variables load order

6 messages · Page 1 of 1 (latest)

night pasture
#

Hello! According to the documentation (https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#environment-variable-load-order) it seems that if I have a same variable defined in the .env.development and .env.local it should prefer the value in the .env.local if I run a development mode. For some reasin it still reads it from the .env.development. Any ideas why?

Thanks!

Learn to add and access environment variables in your Next.js application.

burnt raptorBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

icy pond
#

This effectively means your .env.development.local is going to be checked before .env.local

#

.env.local is more like a sample environment variable file.

night pasture
#

But I do not have .env.develpoment.local I have .env.develompent only. As I understand this list should be read from bottom to top if the same variable exist.

  1. process.env
  2. .env.$(NODE_ENV).local
  3. .env.local (Not checked when NODE_ENV is test.) <-- SAME VARIABLE HERE (sholdn't it prefer that?)
  4. .env.$(NODE_ENV) <-- SAME VARIABLE HERE (.env.development)
  5. .env