Search code examples
javascriptangularjsnode.jszshrcfilepicker

Having trouble setting up enviorment variable MEAN stack .zshrc


I am using ZSH and my the environment variable is this:

FILEPICKER='xxxxxxxxxxx'
export FILEPICKER

I know that the .zshrc is set up properly because have had access to my environment variables in previous projects.

I am having trouble figuring out how to access this in my MEAN app.

This is my app.js file that is throwing the error:

var app = angular.module('app', ['addCarCtrl', 'galleryCtrl','detailCtrl','userCtrl', 'ngRoute', 'angular-filepicker'])

app.config(function($routeProvider, filepickerProvider){
    //The route provider handles the client request to switch route
    $routeProvider.when('/addCar', {
        templateUrl: 'partials/addCar.html',
        controller: 'addCarController'
    })
    .when('/gallery', {
        templateUrl: 'partials/gallery.html',
        controller: 'galleryController'
    })
    .when('/detail/:id', {
        templateUrl: 'partials/detail.html',
        controller: 'detailController'
    })
    .when('/login', {
      templateUrl: 'partials/login.html',
      controller: 'userController'
    })
    .when('/', {
      templateUrl: 'partials/home.html'
    })

    filepickerProvider.setKey(FILEPICKER);

});

Do I need a process.env somewhere?


Solution

  • Okay my problem is that you cannot access environment variables from the front end and I was calling them correctly with process.env.ENV_VAR

    This link what I used to get around this issue:

    https://medium.com/@kudresov/a-better-way-to-inject-environmental-variables-in-angular-d3b2d01a3c5e#.wrv2sc17g