<bdo id='etac1'></bdo><ul id='etac1'></ul>
<i id='etac1'><tr id='etac1'><dt id='etac1'><q id='etac1'><span id='etac1'><b id='etac1'><form id='etac1'><ins id='etac1'></ins><ul id='etac1'></ul><sub id='etac1'></sub></form><legend id='etac1'></legend><bdo id='etac1'><pre id='etac1'><center id='etac1'></center></pre></bdo></b><th id='etac1'></th></span></q></dt></tr></i><div id='etac1'><tfoot id='etac1'></tfoot><dl id='etac1'><fieldset id='etac1'></fieldset></dl></div>

<small id='etac1'></small><noframes id='etac1'>

<legend id='etac1'><style id='etac1'><dir id='etac1'><q id='etac1'></q></dir></style></legend>
    1. <tfoot id='etac1'></tfoot>

      1. Node.js:如何为 prod 和 staging 设置不同的变量

        Node.js: How to setup different variables for prod and staging(Node.js:如何为 prod 和 staging 设置不同的变量)

          <i id='MgKdp'><tr id='MgKdp'><dt id='MgKdp'><q id='MgKdp'><span id='MgKdp'><b id='MgKdp'><form id='MgKdp'><ins id='MgKdp'></ins><ul id='MgKdp'></ul><sub id='MgKdp'></sub></form><legend id='MgKdp'></legend><bdo id='MgKdp'><pre id='MgKdp'><center id='MgKdp'></center></pre></bdo></b><th id='MgKdp'></th></span></q></dt></tr></i><div id='MgKdp'><tfoot id='MgKdp'></tfoot><dl id='MgKdp'><fieldset id='MgKdp'></fieldset></dl></div>
              <tbody id='MgKdp'></tbody>
            <tfoot id='MgKdp'></tfoot>

              1. <small id='MgKdp'></small><noframes id='MgKdp'>

                • <bdo id='MgKdp'></bdo><ul id='MgKdp'></ul>
                  <legend id='MgKdp'><style id='MgKdp'><dir id='MgKdp'><q id='MgKdp'></q></dir></style></legend>
                  本文介绍了Node.js:如何为 prod 和 staging 设置不同的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I'm using Express and I need to use different credentials for each server (staging and production).

                  I could setup the variables in the server.coffee file but then I'd need to access those variables in different files.

                  server.coffee:
                  
                  app.configure 'production', () ->
                   app.use express.errorHandler()
                  

                  What's the solution? Setup the variables and then export them?

                  解决方案

                  ./config.js

                  var development = {
                    appAddress : '127.0.0.1:3000',
                    socketPort : 4000,
                    socketHost : '127.0.0.1',
                    env : global.process.env.NODE_ENV || 'development'
                  };
                  
                  var production = {
                    appAddress : 'someDomain.com',
                    socketPort : 4000,
                    socketHost : '8.8.8.8',
                    env : global.process.env.NODE_ENV || 'production'
                  };
                  
                  exports.Config = global.process.env.NODE_ENV === 'production' ? production : development;
                  

                  ./app.js

                  var cfg = require('./config').Config;
                  
                  if (cfg.something) { // switch on environment
                    // your logic
                  }
                  

                  这篇关于Node.js:如何为 prod 和 staging 设置不同的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  <i id='67556'><tr id='67556'><dt id='67556'><q id='67556'><span id='67556'><b id='67556'><form id='67556'><ins id='67556'></ins><ul id='67556'></ul><sub id='67556'></sub></form><legend id='67556'></legend><bdo id='67556'><pre id='67556'><center id='67556'></center></pre></bdo></b><th id='67556'></th></span></q></dt></tr></i><div id='67556'><tfoot id='67556'></tfoot><dl id='67556'><fieldset id='67556'></fieldset></dl></div>
                  <legend id='67556'><style id='67556'><dir id='67556'><q id='67556'></q></dir></style></legend>

                  <tfoot id='67556'></tfoot>

                    <small id='67556'></small><noframes id='67556'>

                      <tbody id='67556'></tbody>
                        <bdo id='67556'></bdo><ul id='67556'></ul>