packageroot return the closest parent or current directory that contains a package.json example var packageroot = require('packageroot'); packageroot('./',function(err,root){ console.log(root); // if im in /root/package/test it would print // /root/package });