[Minor] Fixed require()ing in route-loading example #1157

wants to merge 1 commit into


None yet

2 participants


You're now able to require() in loaded routes.

@tj tj commented on the diff Aug 1, 2012
@@ -15,7 +14,15 @@ module.exports = function(app, db){
// the file with vm.runInNewContext()
// instead of loading it with require(). require's
// internals use similar, so dont be afraid of "boot time".
- var context = { app: app, db: db };
+ var context = {
+ app: app
+ , db: db
+ // sinde __dirname, __filename and require aren't included
+ // in the global scope, they need to be included manually
+ , __dirname: __dirname
tj Aug 1, 2012 Member

this wont be the right dirname, need to path.dirname(file)


Example doesn't even exist anymore. :D

@buschtoens buschtoens closed this Dec 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment