N
Nuxtβ€’9mo ago
DANANZ M1

Missing NODE_ENV in nuxt

does nuxt has an alternative to config.NODE_ENV === 'development'? I mean, how can I tell if Im in local devlopment server or production build?
11 Replies
Oregon
Oregonβ€’9mo ago
I'm using process.env.NODE_ENV in nuxt.config
manniL
manniLβ€’9mo ago
yes, there is πŸ˜„ in the config you can use $production and $development (top-level) to set different values Even recorded a video about that releasing tomorrow πŸ˜„
DANANZ M1
DANANZ M1OPβ€’9mo ago
That's weird.. when trying to access config.NODE_ENV it's undefined. Does process.env.NODE_ENV will work instead?
manniL
manniLβ€’9mo ago
@DANANZ M1 config.NODE_ENV is not a thing
manniL
manniLβ€’9mo ago
Alexander Lichter
YouTube
😲 An environment-aware Nuxt Configuration
🎬Finally your app is in production - amazing! But how can we ensure that certain configurations or even whole modules are only loaded in dev, or only in production? Would it be even possible to change the nuxt configuration for test environments? A common way is using process.env.NODE_ENV - but luckily, Nuxt provides a more descriptive and foolp...
DANANZ M1
DANANZ M1OPβ€’9mo ago
You actually just posted a video about it πŸ˜… Keep on with the great content! Love it πŸ’― Got my answer thanks!
manniL
manniLβ€’9mo ago
I told you I will πŸ˜„ Glad to hear you enjoy my content πŸ™
Got my answer thanks!
Awesome! πŸ™Œ
Filipe Crespo Dev
Filipe Crespo Devβ€’9mo ago
when I use this in the test it doesn't work, I use build and when I run nuxt it changes the env to production and in the log there is this message WARN Changing NODE_ENV from test to production, to avoid unintended behavior.
Flo
Floβ€’9mo ago
That's on purpose... I've had the github issue related to that recently. Gist is: It will always be production when running a production build.
manniL
manniLβ€’9mo ago
yes and no. I also mentioned that in
manniL
manniLβ€’9mo ago
GitHub
Load nuxt config with different envName for env-specific configs ...
Hey all πŸ‘‹ c12 provides us with the amazing opportunity to add env-specific configs to the nuxt config (also covered in my video), therefore relying on NODE_ENV by default. While it is technically p...
Want results from more Discord servers?
Add your server