Load local.env.js in Angular - full stop

I have set some environment variables in the local.env.js file and I can see in the Gruntfile that local.env.js is accessing and its content is being put into localConfig but I cannot access them when process.env.MY_ENV_VAR

What am I missing? Is there any other configuration or requirement that I have to fulfill?

+3


source to share


2 answers


Have you tried setting real environment variables in the shell you are grunting from?

An example of using your variable name, put the following line in .bash_profile (if you run bash):



export MY_ENV_VAR="string value"

      

Nodejs native process grabs these environment variables and passes them in to grunt.

0


source


I faced this problem. My question was grumbling. I stopped the grunt feed process, made changes, and then started the feed in the console. Grunt did not update the environment variable assignment.

Here's an example of using a variable.



module.exports = {
  // MongoDB connection options
  mongo: {
    uri: process.env.DB_DEV_URI
  },

  seedDB: true
};

//DB_DEV_URI is assigned in the local.env.js file

      

0


source







All Articles