全局variablesexpress node.js

我想获得variables,我可以在我的代码中find一个解决scheme,但这不是很干净

//environment.js module.exports.appName = "appName"; 

和我的app.js

 var express = require('express') , routes = require('./routes/main') , user = require('./routes/user') , http = require('http') , path = require('path'); var app = express(); environment = require('./environment'); app.configure(function(){ app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser('your secret here')); app.use(express.session()); app.use(app.router); app.use(require('stylus').middleware(__dirname + '/public')); app.use(express.static(path.join(__dirname, 'public'))); }); app.configure('development', function(){ app.use(express.errorHandler()); }); app.get('/', routes.home); app.get('/users', user.list); http.createServer(app).listen(app.get('port'), function(){ console.log("Express server listening on port " + app.get('port')); }); 

这样我的var工作,我可以访问environment.appName无处不在,但是Y会有更好的解决scheme

谢谢

       

网上收集的解决方案 "全局variablesexpress node.js"