Meteor project path from a smartpackage

I was looking for a way to look up the meteor project path from a smart package (e.g.: obtain the path of the directory where the .meteor folder is ...). I was not able to do it using node's __dirname and __filename because somehow in meteor they are not avaiable. Any tips ?

As of Meteor 0.6.0 this would be:

var path = Npm.require('path');
var basepath = path.resolve('.');

From a smartpackage (0.6.5+):

var path = Npm.require('path');
var base = path.resolve('.');

base in this case gets you the position of your package ..

/User/username/projects/project/.meteor/local/programm/server/...

.. might even be deeper

but we want

/User/username/projects/project/

.. so split at .meteor

base = base.split('.meteor')[0];


Or as two-liner

var path = Npm.require('path');
var base = path.resolve('.').split('.meteor')[0];;

This works for me in Meteor 0.5.0:

var require = __meteor_bootstrap__.require;
var path = require('path');
var basepath = (path.resolve('.'));

You can actually get access to node:

var __dirname = __meteor_bootstrap__.__dirname;