Since you've got your own scope here, why not just
```js
var parts = __filename.split('/');
parts.pop();
var __dirname = parts.join('/');
```