<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 设置不同的变量

        时间:2024-04-19

          <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 设置不同的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将骨干路由器应用于完整路径,而不是哈希 下一篇:CoffeeScript - 不允许在 Angular 表达式中引用 DOM 节点

                  相关文章

                  <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'>

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