Skip to content
Advertisement

How to set custom path for dotenv in nuxt

I have the following nuxt.config.js, where in the srcDir is pointing to “main-app” and I have placed the .env outside of it. So in the nuxt.config.js, how can set the custom path in line 1

require('dotenv').config({ path: '../.env' })

such that my process.env works enter image description here

Also the buildModules in nuxt.config.js is as follows

buildModules: ["@nuxtjs/fontawesome", "@nuxtjs/dotenv"],

Advertisement

Answer

Actually I need to set the live path of the env in the buildModules section just like follows

 buildModules: ["@nuxtjs/fontawesome", ['@nuxtjs/dotenv', { path: './' }]],
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement