 +            "process.on('uncaughtException', function (err) {"
 +              "console.log(err.stack);"
 +            "});"
++
++            // Save node-webkit version
++            "process.versions['node-webkit'] = " NW_VERSION_STRING ";"
 +        ));
 +        script->Run();
 +    }

 
     initializeV8IfNeeded();
 
@@ -328,7 +334,43 @@ bool V8DOMWindowShell::initContextIfNeeded()
 
     updateDocument();
 

+#endif
+            "process.chdir(require('path').dirname(process.mainModule.filename));"
+            "process.mainModule.paths = require('module')._nodeModulePaths(process.cwd());"
+        ));
+        script->Run();
+    }
+
+    if (use_node || is_nw_protocol) {
+        v8::Local<v8::Script> script = v8::Script::New(v8::String::New(
+            // Use WebKit's console globally
+            "global.console = console;"
+
