dotenv-module
dotenv-module copied to clipboard
.env.dev file is not working in nuxt plugin
Hello.
.env.dev file is not working in nuxt plugin.
i created .env.dev file and run script "nuxt --dotenv .env.dev".
print env variable in my custom nuxt plugin.
console.log(process.env) #output :: {}
But .env file is working.
not working with nuxt3
nuxt.config.js is as follows
import { defineNuxtConfig } from "nuxt/config"
export default defineNuxtConfig({
css : ['vuetify/lib/styles/main.sass', '@mdi/font/css/materialdesignicons.min.css'],
modules: [
['@nuxtjs/dotenv', { filename: '.env.development' }]
],
runtimeConfig: {
apiSecret: '123',
public: {
SITE_NAME: process.env.SITE_NAME || 'Ghost'
}
},
build : {
transpile :[
'vuetify',
]
},
vite : {
define : {
'process.env.DEBUG' : false,
}
}
})
.env.development file present in source directory but it give error as follows
ERROR Cannot start nuxt: Cannot read properties of undefined (reading 'srcDir')