← Back to list

The Silent Bug: Why Nuxt Couldn’t Read My .env File

I recently ran into a strange issue while migrating to Nuxt 4. It turns out my .env files weren't being detected at all. I’ve been dealing…

Chatri Ngambenchawong · 2026-03-20 07:11 · 0 claps · 1.1 min read
#nuxtjs #environment #nuxt #vuejs
Open on Medium ↗
Wiki topics: 🌐 · Web Development

The Silent Bug: Why Nuxt Couldn’t Read My .env File

I recently ran into a strange issue while migrating to Nuxt 4. It turns out my .env files weren't being detected at all. I’ve been dealing with some family matters lately (my mother was hospitalized), so I only just managed to sit down and debug this.

The Issue

For some reason, my .env file encoding had switched from UTF-8 to UTF-16 LE / UTF-16. (I think i can be from AI Agent that call powershell command to complete some task. Since I keep my .env in .gitignore, it wasn't immediately obvious what had changed in the file properties.

How to Fixed

If you’re facing this, here’s how to fix it in VS Code:

  1. Open your .env file.
  2. Look at the Status Bar (bottom right). If it says **UTF-16**, click on it.
  3. Select “Save with Encoding”.
  4. Choose UTF-8.

After saving, I re-ran the app and Gotcha! the variables were correctly injected intoruntimeConfig Back to coding!

Original Post: https://naiwaen.debuggingsoft.com/2026/03/the-silent-bug-why-nuxt-couldnt-read-my-env-file/

Reference


메타데이터
post_id
9b2e142d30a5
slug
the-silent-bug-why-nuxt-couldnt-read-my-env-file-9b2e142d30a5
url
https://medium.com/@pingkunga/the-silent-bug-why-nuxt-couldnt-read-my-env-file-9b2e142d30a5
canonical_url
https://medium.com/@pingkunga/the-silent-bug-why-nuxt-couldnt-read-my-env-file-9b2e142d30a5
author_url
https://medium.com/@pingkunga
status
ok
fetched_at
2026-06-20 20:29:01