查看来自https://github.com/twilson63/express-coffee/blob/master/src/config/index.coffee#L13的代码有以下内容:
#### Config file
# Sets application config parameters depending on `env` name
exports.setEnvironment = (env) ->
console.log "set app environment: #{env}"
switch(env)
when "development"
exports.DEBUG_LOG = true
exports.DEBUG_WARN = true
exports.DEBUG_ERROR = true
exports.DEBUG_CLIENT = true
exports.DB_HOST = 'localhost'
exports.DB_PORT = "3306"
exports.DB_NAME = 'mvc_example'
exports.DB_USER = 'root'
exports.DB_PASS = 'root'
when "testing"
exports.DEBUG_LOG = true
exports.DEBUG_WARN = true
exports.DEBUG_ERROR = true
exports.DEBUG_CLIENT = true
when "production"
exports.DEBUG_LOG = false
exports.DEBUG_WARN = false
exports.DEBUG_ERROR = true
exports.DEBUG_CLIENT = false
else
console.log "environment #{env} not found"
当我尝试输出时,modules.export
我从控制台得到一个空数组!
exports.DB_NAME
例如,如果我有一个需要此信息的模块,如何正确使用?
console.log config.DB_NAME
返回undefined
从另一个模块调用的 if。
非常感谢任何建议。