I have an npm module that requires a config file (provided by the user). Is there a way to tell that module to look for a specific file in the user's directory ?
I want something like this:
In the module
const config = require(USER_ROOT_DIRECTORY + '/config.json');
In the user's project
/node_modules (contains the module file)
/src/index.js
/config.json
In the index.js file
const module = require('module'); // will automatically get the config.json file's content
via Massinissa Mokhtari
No comments:
Post a Comment