I\'m trying to include some simulation data with a node module (module B) and then be able to reference that data from the calling module (module A). The data is a text file
When packaging a module you can use the files property of package.json to bundle any assets along with your module.
Then, in that module, you can use a relative path to reference your included asset.
Imagine a module with this file structure:
-assets
|-data.txt
index.js
In your package.json you might have a files
section that looked like:
files: [
'index.js',
'assets/data.txt'
]
And in index.js you could expose your asset data like so:
let fs = import 'fs';
function getAssetData() {
return fs.readFileSync('./assets/data.txt')
}
module.exports = { getAssetData };