How do I access process.env in Meteor?


Question

I have tried:

alert(process.env.MONGO_URL);

everywhere is my Meteor project and always get:

Uncaught ReferenceError: process is not defined 

I'm not sure what I'm doing wrong. Do I need to include something? Meteor is written in javascript and all the same APIs are available so why isn't process defined?

1
6
1/15/2013 5:01:51 PM

Accepted Answer

You could try

if (Meteor.isServer) {
  console.log(process.env);
}
7
1/15/2013 5:12:49 PM

You must get the environment from the server side. Try the following.

//In the client side
if (Meteor.isClient) {

   Meteor.call('getMongoUrlEnv', function(err, results) {
     alert("Mongo_URL=",results);
   });

}


if (Meteor.isServer) {

   Meteor.methods({
      getMongoUrlEnv: function(){
           var mongoURL = process.env.MONGO_URL;
           return mongoURL;
      }
   });
}

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon