Activities

mateusavila

mateusavila posted a new question

dotenv-module •

Using multiple .env files

Hi

In my project, I needed to use 2 .env files, like:
.env.development
.env.production

Using the main module, only get the default .env file. How I get the correct .env in correct environment?

powerlimit

powerlimit posted a new question

dotenv-module •

Merging .env files

Is it possible to merge env files? For example, I have .env and .env.local files in my project. .env is the main file which is used in production mode. In development mode I want use the same .env file, but with overwriting some properties from .env.local file. How can i do this?

z0w13

z0w13 posted a new feature request

dotenv-module •

idea System vars should overwrite dotenv vars

What problem does this feature solve?

In most places where dotenv is used system env vars override the dotenv vars, however dotenv-module does the exact opposite, swapping this around would give the expected result when using systemvars: true

ricardogobbosouza

ricardogobbosouza posted a new feature request

dotenv-module •

idea Run CircleCI on PRs

What problem does this feature solve?

Run CircleCI on PRs

skyrpex

skyrpex posted a new bug report

dotenv-module •

bug Problem with transpiled file related to systemvars

Version

v1.3.0

Reproduction link

https://couldnt-get-codesandbox-to-work

Steps to reproduce

I'm using yarn 1.17.3 and dotenv-module 1.3.0. (problem also occurs on npm)

Install those and try using systemvars: true. No vars will be loaded.

What is expected ?

This is what I get when building the dist/index.js file myself, which is OK:

  if (options.systemvars) {
    Object.keys(process.env).map(function (key) {
      if (!(key in envConfig)) {
        envConfig[key] = process.env[key];
      }
    });
  }

What is actually happening?

But this is what I get when installing the package:

  if (options.systemvars) {
    Object.keys(process.env).map(function (key) {
      if (!key in envConfig) {
        envConfig[key] = process.env[key];
      }
    });
  }

The condition always returns false and no vars are loaded.

kendavila

kendavila posted a new question

dotenv-module •

Documentation is outdated

Can you update this section: https://github.com/nuxt-community/dotenv-module#using-env-file-in-nuxtconfigjs? You are showing a commonjs approach but the latest version of nuxt, the nuxt.config.js uses an ESM approach.

gtso86

gtso86 posted a new question

dotenv-module •

Build using .env.staging file

When I use .env in vue projects I can choose which .env I want to use when I build the app. How I can do the same using nuxt dotenv-module?

What I already tried:
create a new scripts passing NODEENV without success "scripts": { "staging": "NODEENV=staging nuxt build",
}

What I should do to use multiple .env files for each environment?

gkshi

gkshi posted a new question

dotenv-module •

Variables inside .env file

Hello. I want to use global environment variables in my .env file like that:
APIURL=${APIURL}

The variable declaration is higher (in docker-compose.yml).

The value must be an url. But in process.env on the client side I see not parsed string:
console.log(process.env.APIURL) // ${APIURL}

How can I set values in .env correctly? Thank you for your help.

trentpeterson

trentpeterson posted a new feature request

dotenv-module •

idea Empty only option array should result in nothing going into context.env

What problem does this feature solve?

Currently, if the only option is specified with an empty array, default logic is used and all values are placed into context.env and thus provided to the client.

I think that an empty array should signal that I do not want anything copied into context.env. If I do not specify an only option/array at all, I would expect the default behavior to apply and all values would be placed into context.env.

As a workaround, I specify a name in the array that doesn't correspond to any key:

['@nuxtjs/dotenv', { only: ['nothing'] }],

Related, I agree with this comment on #7 that there should be a warning that all values are available on the client unless only is used.

What does the proposed changes look like?

This configuration

['@nuxtjs/dotenv', { only: [] }],

results in nothing in .env going into context.env.

megusta420

megusta420 posted a new bug report

dotenv-module •

bug Env vars are empty after module install

Version

1.3.0

Reproduction link

http://no.link

Steps to reproduce

  1. yarn add @nuxtjs/dotenv
  2. edit nuxt.config.js (modules property): https://pastebin.com/13Btdxyt
  3. add some var to .env like this: SOMEKEY=SOMEKEYVALUE
  4. try to output value of process.env: https://pastebin.com/K4HAAuJq

What is expected ?

output of .env file vars array

What is actually happening?

empty object "{}"

nuxt version "nuxt": "^2.0.0",

beardedpayton

beardedpayton posted a new bug report

dotenv-module •

bug Nuxt dotenv-module and deploying to Netlify

Version

1.3.0

Reproduction link

https://github.com/beardedpayton/paytonburdette.com-v2

Steps to reproduce

Install module

npm i nuxtjs/dotenv

** cant include the @ symbol here, it thinks I'm trying to tag a user in the issue

Require module in nuxt.config.js

require('dotenv').config()

Add module to modules array in nuxt.config.js

modules: ["@nuxtjs/dotenv"]

Use "module in codebase with process.env.ENVVARNAME

What is expected ?

Works as expected locally. I can read from my .env file fine.

When deploying to Netlify and using build environment variables, I should be able to read from those variables within my project.

What is actually happening?

I cannot read variables from my build environment variables established with Netlify. I can only read from them if a .env file is present.

aloiseau17

aloiseau17 posted a new question

dotenv-module •

Nuxt dotenv options require in nuxt-config.js doesn't work

Hi,

I tried to use nuxt-dotenv with fileaname custom options like that:

modules: [
    ['@nuxtjs/dotenv', {
      filename: '.env.dev',
  }],
  ],

It's working fine in my app but not in my nuxt-config.js
I import dotenv at the top:

require('dotenv').config()

Before that I had to add the dotenv dependency to my package.json.
But the custom .env file wasn't read. Only .env is working.

PrimozRome

PrimozRome posted a new question

dotenv-module •

Variables from .env are not written into process.env

I have .env file in my root Nuxt.js project but the variables are not read into process.env. ž

I have added the module following the instruction here https://github.com/nuxt-community/dotenv-module. Module looks to be loaded properly but process.env is empty object.

Any idea why?

beardedpayton

beardedpayton posted a new question

dotenv-module •

Env variables not working once deployed to Netlify

I saw the comment here: https://github.com/nuxt-community/dotenv-module/issues/13#issuecomment-375957024

When the env file is not present in my dist folder, my env variables are not working. Everything works as expected locally.

ScreamZ

ScreamZ posted a new question

dotenv-module •

Can you please update

Hello @JulienTant,
This is release in code since months (https://github.com/nuxt-community/dotenv-module/commit/3e2696341dcde954f510c48e669bd207794393d2)

but not on npm… (dist folder is not up to date) "version": "1.1.1"

{
  modules: [
    ['@nuxtjs/dotenv', { filename: '.env.prod' }],
  ]
}

Could you please update repositories.

Regards

alanaasmaa

alanaasmaa posted a new question

dotenv-module •

How to use with PM2 process manager.

Hello,

I can't figure out how to get this to work with PM2.
I would like to use .env file not ecosystem.

I have tried this => require('dotenv').config({ path: path.join(__dirname, '../.env') })
But i think this does not work because pm2 start nuxt from ./node_modules/nuxt/bin/nuxt-start

I want to set API_URL for my axios.

ErvalhouS

ErvalhouS posted a new question

dotenv-module •

Not reading `process.env` variables set on Heroku on Plugin config

I have a /plugins/AutoForceService.js as follows:

export default ({ app }, inject) => {
  let autoForceService = new AutoForceService({
    axios: app.$axios,
    group: process.env.GROUP,
    apiKey: process.env.AUTODROMO_API_KEY,
    baseURL: process.env.API_BASE_URL,
  });
  Vue.use(autoForceService);

  app.autoForceService = autoForceService;
};

If I do deploy this app to Heroku with a .env file everything works fine, but I don't want to keep that file on my git tree. Heroku supports process.env variables, but when using this service they are being resolved as undefined. Axios requests that are not in this service scope works fine, even using the same variables. Axios plugin is initialized like this:

export default function ({$axios}) {
  $axios.onRequest((config) => {
    config.headers.common['Authorization'] = `Token token=${process.env.AUTODROMO_API_KEY}`;
    config.headers.common['Content-Type'] = 'application/json';
    config.baseURL = `${process.env.API_BASE_URL}`;
  })
}

Is there a workaround?

wienska

wienska posted a new question

dotenv-module •

Use different env files for different environments

Hi! Could you tell how to use different env files (.env.dev, .env.prod etc.) for different environments? How can I configure filename in nuxt.config module depending on deployment command?

wienska

wienska posted a new question

dotenv-module •

Use different env files for different environments

Hi! Could you tell how to use different env files (.env.dev, .env.prod etc.) for different environments? How can I configure filename in nuxt.config module depending on deployment command?

JulienTant

JulienTant resolved the question #c2

dotenv-module •

variables not defined on init

Hi,

The dotenv-module won't overload the environment variables of the process running your build.

If you need to use variables from your .env file at this moment (and it looks like you do), just append require('dotenv').config() to your nuxt.config.js :

require('dotenv').config()

module.exports = {
    // your usual nuxt config.
}

This will works thanks to the dotenv library provided by this module as a dependency. If you decided to ignore some values from your .env file in the module configuration, this won't apply here.

Hope this help, i will update the README file with this, it can be useful !