Describe the bug
When NODE_ENV=production is set in the shell environment, slidev (dev server) renders a completely blank white page. The JavaScript console shows: ReferenceError: __DEV__ is not defined.
Root cause: @slidev/client/env.ts uses export const mode = __DEV__ ? 'dev' : 'build', but __DEV__ is not a standard Vite variable — it was auto-defined by older Vite versions via a Vue compatibility shim, and Vite 8 no longer guarantees it. When NODE_ENV=production is present, Vite 8's import.meta.env.DEV reports false even in dev server mode, and the __DEV__ define (which Slidev's getDefine() correctly maps to options.mode === "dev") doesn't take effect.
The fix is a one-line change: replace __DEV__ with Vite's standard import.meta.env.DEV, which correctly reflects the Vite mode regardless of NODE_ENV.
Minimal reproduction
Steps to reproduce:
export NODE_ENV=production
pnpm create slidev (or npm create slidev@latest) — Slidev v52.17.0
pnpm run dev
- Open
http://localhost:3030 → completely blank page
- Check console:
ReferenceError: __DEV__ is not defined
You can use https://sli.dev/new to create a new project.
This is reproducible whenever NODE_ENV=production is present — common in CI/CD environments, Docker containers, or developer machines with global NODE_ENV set.
Proposed fix
In @slidev/client/env.ts, line 5:
- export const mode = __DEV__ ? 'dev' : 'build'
+ export const mode = import.meta.env.DEV ? 'dev' : 'build'
import.meta.env.DEV is the standard Vite API for detecting dev mode. It correctly reports true in dev server and false in production builds, and is NOT affected by NODE_ENV. This fix:
- ✅ Fixes the bug when
NODE_ENV=production
- ✅ No change in behavior when
NODE_ENV is unset or development
- ✅ No change in production build behavior (
import.meta.env.DEV is false at build time)
- ✅ Eliminates dependency on the non-standard
__DEV__ global
Workaround (until fixed)
// package.json
"dev": "NODE_ENV=development slidev"
Environment
- Slidev version: 52.17.0
- Node: v26.2.0
- pnpm: v11.11.0
- OS: macOS 26.5.2
Additional context
Related to closed issue #2142 (same error, closed without root cause analysis — the reporter likely had NODE_ENV=production set without realizing it).
Describe the bug
When
NODE_ENV=productionis set in the shell environment,slidev(dev server) renders a completely blank white page. The JavaScript console shows:ReferenceError: __DEV__ is not defined.Root cause:
@slidev/client/env.tsusesexport const mode = __DEV__ ? 'dev' : 'build', but__DEV__is not a standard Vite variable — it was auto-defined by older Vite versions via a Vue compatibility shim, and Vite 8 no longer guarantees it. WhenNODE_ENV=productionis present, Vite 8'simport.meta.env.DEVreportsfalseeven in dev server mode, and the__DEV__define (which Slidev'sgetDefine()correctly maps tooptions.mode === "dev") doesn't take effect.The fix is a one-line change: replace
__DEV__with Vite's standardimport.meta.env.DEV, which correctly reflects the Vite mode regardless ofNODE_ENV.Minimal reproduction
Steps to reproduce:
export NODE_ENV=productionpnpm create slidev(ornpm create slidev@latest) — Slidev v52.17.0pnpm run devhttp://localhost:3030→ completely blank pageReferenceError: __DEV__ is not definedYou can use https://sli.dev/new to create a new project.
This is reproducible whenever
NODE_ENV=productionis present — common in CI/CD environments, Docker containers, or developer machines with globalNODE_ENVset.Proposed fix
In
@slidev/client/env.ts, line 5:import.meta.env.DEVis the standard Vite API for detecting dev mode. It correctly reportstruein dev server andfalsein production builds, and is NOT affected byNODE_ENV. This fix:NODE_ENV=productionNODE_ENVis unset ordevelopmentimport.meta.env.DEVisfalseat build time)__DEV__globalWorkaround (until fixed)
Environment
Additional context
Related to closed issue #2142 (same error, closed without root cause analysis — the reporter likely had
NODE_ENV=productionset without realizing it).