Skip to content

loadEnvConfig only work on next@canary version #77178

@stevenho0811

Description

@stevenho0811

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/exciting-galileo-7wjl3h

To Reproduce

  1. Start Application, run pnpm dev
  2. I put a console.log print loadedEnvFiles return from loadEnvConfig in next.config.ts`, you can see the variable from Terminal.
  3. next@15.2.2:
  4. See Terminal
[]
  1. pnpm install next@15.2.2-canary.7
  2. See Terminal
[
  {
    path: '.env',
    contents: 'NEXT_PUBLIC_API_URL=https://example.com/api\n',
    env: {}
  }
]
  1. pnpm install next@15.3.0-canary.10
  2. See Terminal
[
  {
    path: '.env',
    contents: 'NEXT_PUBLIC_API_URL=https://example.com/api\n',
    env: {}
  }
]

it should work on stable version, not canary version ...

Current vs. Expected behavior

next@15.2.2
CodeSandbox

Image


next@15.2.2-canary.7 or next@15.3.0-canary.10
CodeSandbox

Image

Image

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:22:58 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8132
  Available memory (MB): 24576
  Available CPU cores: 10
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.5.0
Relevant Packages:
  next: 15.2.2 // Latest available version is detected (15.2.2).
  eslint-config-next: 15.2.2
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions