Skip to content

Instantly share code, notes, and snippets.

@antonlvovych
antonlvovych / root.js
Last active March 6, 2022 23:16
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 root = require('root'); // In root will be absolute path to your application