diff --git a/lib/app.js b/lib/app.js
index <HASH>..<HASH> 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -23,6 +23,14 @@ app.templates = {};
 app.PRODUCTION  = 'production';
 app.DEVELOPMENT = 'development';
 
+// Set the NODE_ENV variable as this is used by Express, we want the
+// environment to take precedence but allow it to be set using the config file
+// too.
+if (process.env.NODE_ENV) {
+  options.env = process.env.NODE_ENV;
+}
+process.env.NODE_ENV = options.env;
+
 // Sort out the port.
 (function (url) {
   var port = ''; //process.env.PORT;
Set NODE_ENV from the config file unless already defined