Install on your Project. npm install dirname-for-module Usage import { __dirname } from "dirname-for-module"; console.log(__dirname); // outputs "/path/to/the"