Skip to content

Instantly share code, notes, and snippets.

@NguyenTrungTin
Forked from antonlvovych/root.js
Last active April 16, 2019 04:58
Show Gist options
  • Save NguyenTrungTin/91fb2eee782e89553d208dc55c92374a to your computer and use it in GitHub Desktop.
Save NguyenTrungTin/91fb2eee782e89553d208dc55c92374a to your computer and use it in GitHub Desktop.
Get root path of node.js application
var path = require('path');
module.exports = (function () {
return path.dirname(require.main.filename || process.mainModule.filename);
})();
// Example of usage:
var rootPath = require('rootPath'); // In root will be absolute path to your application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment