Closed rachel-carvalho closed 13 years ago
Somehow my __dirname isn't my app's directory but the zappa@0.2.0
directory where npm installed it, i.e. running this
require('zappa') -> console.log __dirname
in /tmp
doesn't print /tmp
as I expected…
In plain node it works:
console.log(__dirname)
Inside a zappa block we lose access to __dirname
and friends, which is one of the main reasons I'm thinking of moving to a @
based API in 0.3.0.
Meanwhile, we fake it by using module.parent.filename
, which is the first file that required zappa in a process. It works in many common scenarios but is ultimately bound to fail.
Until 0.3.0 is released, you can use this if you're having problems:
require('zappa') {__dirname}, ->
console.log __dirname
set views: __dirname + '/views'
When running an app from a different directory, it seeks the views folder in cwd, instead of in the app dir:
In order for this to work, we have to explicitly set the views dir in my app, like we'd do in an express app:
It'd be nice if zappa could set this option by default.