7

私が試してみました:

alert(process.env.MONGO_URL);

どこにでも私のMeteorプロジェクトがあり、常に次のものを取得します。

Uncaught ReferenceError: process is not defined 

何が間違っているのかわかりません。何かを含める必要がありますか?Meteorはjavascriptで記述されており、すべて同じAPIが利用できるのに、なぜプロセスが定義されていないのですか?

4

3 に答える 3

8

あなたは試すことができます

if (Meteor.isServer) {
  console.log(process.env);
}
于 2013-01-15T17:12:49.387 に答える
4

サーバー側から環境を取得する必要があります。次のことを試してください。

//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;
      }
   });
}
于 2014-07-24T21:16:35.290 に答える
-2

この機能でサーバー側環境をリクエストできます。

//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];;
      }
   });
}
于 2017-08-08T05:38:34.153 に答える