Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

als-module-info

alexsorkin4MIT0.1.1

A utility for easy retrieval of __dirname and __filename in Node.js ES6 modules.

__dirname, __filename, dirname, filename, module, path, ES6, nodejs, esm, import.meta

readme

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