alert(process.env.MONGO_URL);
到处是我的流星项目,一定可以得到:
Uncaught ReferenceError: process is not defined
我不知道我在做什么错。我需要包括什么吗?流星是用JavaScript编写的,所有相同的API都可用,所以为什么不定义流程?
alert(process.env.MONGO_URL);
到处是我的流星项目,一定可以得到:
Uncaught ReferenceError: process is not defined
我不知道我在做什么错。我需要包括什么吗?流星是用JavaScript编写的,所有相同的API都可用,所以为什么不定义流程?
你可以尝试
if (Meteor.isServer) {
console.log(process.env);
}
您必须从服务器端环境。尝试以下操作。
//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;
}
});
}
您可以使用此功能请求服务器端环境。
//In the client side
if (Meteor.isClient) {
Meteor.call('getEnv', "VARIABLE_NAME", function(err, results) {
alert(results);
});
}
if (Meteor.isServer) {
Meteor.methods({
getEnv: function(node){
return process.env[node];;
}
});
}
的重复[检测环境Meteor.js?](http://stackoverflow.com/questions/14184643/detecting-environment-with-meteor-js) –