dotenv-module icon indicating copy to clipboard operation
dotenv-module copied to clipboard

.env.dev file is not working in nuxt plugin

Open ChoWonmin opened this issue 2 years ago • 1 comments

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.

ChoWonmin avatar Oct 14 '22 10:10 ChoWonmin

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')

prashantnirgun avatar Jan 10 '23 18:01 prashantnirgun