'How to access a config file from a library installed in node_modules?
I published a nodejs library to npm registry which includes some configuration files e.g. json, yml etc. In this library, it needs to load these configuration files from local disk. But when this library is used by other nodejs project, these configuration files are located under node_modules/module_name/xxx/*.yml.
How can I specify the path in the library to load these configuration files?
const fs = require('fs');
let rawdata = fs.readFileSync('config/spec.yml');
In above code, it loads the file from config/spec.yml path. But if it is used by other module, do I have to change the path to be 'node_modules/xxxx/config/spec.yml'?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
