Skip to content

Instantly share code, notes, and snippets.

@antonlvovych
Last active June 21, 2024 17:35
Show Gist options
  • Save antonlvovych/e2e3e0325abd9023d3a3 to your computer and use it in GitHub Desktop.
Save antonlvovych/e2e3e0325abd9023d3a3 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 root = require('root'); // In root will be absolute path to your application
@sasial-dev
Copy link

Use process.cwd()

@inexas
Copy link

inexas commented Jul 29, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment