Activities

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 !

VitorLuizC

VitorLuizC resolved the question #c7

dotenv-module •

Can't deploy to Netlify when using @Nuxt/dotenv

Its because @nuxtjs/dotenv can't use system's variables when .env file is not found #12.

You can deploy .env file too. It's a bad practice, but works.

JulienTant

JulienTant resolved the question #c6

dotenv-module •

Cannot add private key

I'm not sure how I can help you ?

That module is using this package to load variables from .env file : https://github.com/motdotla/dotenv. You should probably get help there !

Please reopen if I have misunderstood your problem

tamacroft

tamacroft posted a new question

dotenv-module •

Cannot add private key

i have try :
privatekey="-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAAS….." or privatekey:-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAAS…
or
private_key:'-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAAS….'

but result is Certificate object must contain a string "private_key" property.

stuartjnelson

stuartjnelson posted a new question

dotenv-module •

Can't deploy to Netlify when using @Nuxt/dotenv

Hello!

I've been unable to deploy to Netlify when using the plugin.

  • "@nuxtjs/dotenv": "^1.1.0"
  • "nuxt": "^1.0.0"
modules: [
        ['@nuxtjs/dotenv']
]

Netlfiy Error log when using the module
Netfliy log for successful deployment

I've tried a whole bunch of different configurations inside nuxt.config.js but could'nt get anything to work. I don't get the issue when I generate the static site locally just when using Netlify. I have spoke to their support and they can't see the issue. I am wondering if its to do with the NPM WARN about missing optional dependencies? Let me know if you need anymore info!

gijo-varghese

gijo-varghese posted a new question

dotenv-module •

Use system process if .env file is not found

In our team, we would like to use .env file for local development. But it won't be committed to git. And while deploying it will take env variables from server. Right now when I add .env to .gitignore and when I try to build it from where, it throws an error saying that .env file is not found

s-ferdie

s-ferdie posted a new question

dotenv-module •

fs dependency not found

I've follow the instructions to add the dotenv module.
When I run npm run dev I'm getting the following error:

This dependency was not found:

  • fs in ./node_modules/@nuxtjs/dotenv/dist/index.js

To install it, you can run: npm install --save fs

Digging into this npm package its seems to be a security-holder package.
How to solve the error?

koresar

koresar posted a new question

dotenv-module •

Clarify in README should it be devDependecy or dependency

Could someone please clarify if this should be a devDependency or dependency in package.json?

pSchaub

pSchaub posted a new question

dotenv-module •

Hot reload if .env file changes are happening

Hot reloading is not working if you do a simple change on your .env file.

Steps to reproduce:

  1. Start dev server (e.g. with npm run dev or yarn run dev)
  2. Change something in your .env file
sprabowo

sprabowo posted a new question

dotenv-module •

is there way to keep secret key in .env?

i see in my configuration that contain secret code in source code /_nuxt/app.1234132.js .env is loaded in.

thanks

pierre-aurele-martin

pierre-aurele-martin posted a new question

dotenv-module •

is it working with nuxt / express ?

Hello,

Sorry to interrupt here but I really can not manage to achieve a simple thing (read process.env)

#1 - Only way I can read what's in my .env file is by
require('dotenv').config()
in nuxt.config.js

When I'm adding it as a module, it doesn't find anything even if .env is at the root…

#2 still in nuxt.config.js I define :

 env: {
    test: process.env.TEST,
  },

#3
In server/index.js I define :

const test = process.env.test

And it's always undefined…

I've tried a lot and a lot of thing but I think I'm missing something here. Any help will be really appreciate !

thanks !

Decipher

Decipher posted a new question

dotenv-module •

Allow path to .env to be overridden.

Currently this module expects that the .env file to live in the root of the NuxtJS project. I have a usecase where I wish for the .env file to live in another location so it can be shared among multiple projects.

As such, it would be ideal if the module accepted a path option.

PR incoming.