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?
Solved: start by typing node and pressing enter, then type process. env and press enter.
Environment variables are stored in your system shell that you start node. js from. They are a shell feature that node.
The process. env global variable is injected by the Node at runtime for your application to use and it represents the state of the system environment your application is in when it starts. For example, if the system has a PATH variable set, this will be made accessible to you through process. env.
To retrieve environment variables in Node. JS you can use process. env. VARIABLE_NAME, but don't forget that assigning a property on process.
You could try
if (Meteor.isServer) {
console.log(process.env);
}
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;
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With