als-module-info
The als-module-info
is a small function which takes the import.meta
object and returns an object with two properties: __dirname
and __filename
, representing the module's directory and the full path to the module file.
Installation
To install, use npm:
npm install als-module-info
Usage
Import the getModuleInfo
function from the package and use it in your ES6 module:
import getModuleInfo from 'als-module-info';
const {__dirname,__filename} = getModuleInfo(import.meta);
console.log(__dirname); // Outputs the directory of the module
console.log(__filename); // Outputs the path to the module file