Node.js parent path from server.js

My is there c:\nodejs\www\project\bin\server.js

My views are in c:\nodejs\www\project\views

Then in my server.js I have:

.set('views', __dirname + '/views')

But the generated path is: c:\nodejs\www\project\bin\views

How to get the parent of bin folder?

I use Express and Ejs.

Regards

there are two ways of doing this, I can think :

  1. .set('views',__dirname + '../views');

Or

  1. you can use path.join from the path module

    var path = require("path"), .set(path.join(__dirname, '..', 'views'));

these will get your back one parent in the directory structure to find the file.