Skip to content

Cannot load .env file #210

Description

@pnhuyduy

Describe the bug

I cannot load .env variable whether is dev or production mode

My .env. look like this

VITE_SOME_KEY=123

in my code

console.log(import.meta.env, import.meta.env.VITE_SOME_KEY)

the console result

Image

Reproduction

Code above

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600K
    Memory: 42.27 GB / 63.76 GB
  Binaries:
    Node: 18.20.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Users\Admin\AppData\Roaming\npm\yarn.CMD
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.8.0 - C:\Users\Admin\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Chrome: 141.0.7390.108
    Edge: Spartan (44.19041.3636.0), Chromium (140.0.3485.66)
    Firefox: 137.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.19041.3636

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions