Skip to content

Instantly share code, notes, and snippets.

@antonlvovych
antonlvovych / root.js
Last active June 21, 2024 17:35
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