Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bingo347/commonjs-variables-for-esmodules

Simple function for extract node variables __dirname, __filename, require and module from import.meta
https://github.com/bingo347/commonjs-variables-for-esmodules

commonjs esmodules nodejs

Last synced: 19 days ago
JSON representation

Simple function for extract node variables __dirname, __filename, require and module from import.meta

Awesome Lists containing this project

README

        

# commonjs-variables-for-esmodules

Simple function for extract node variables __dirname, __filename, require and module from import.meta

## Install

```bash
npm install --save commonjs-variables-for-esmodules
# or
yarn add commonjs-variables-for-esmodules
```

## Limitations

- node 12.2 or higher
- use only in native ES modules

## Usage

```javascript
import commonjsVariables from 'commonjs-variables-for-esmodules';

const {
__filename,
__dirname,
require,
module
} = commonjsVariables(import.meta);
```

## License

MIT