Loading json file from module


#1

Hi, is there a way to load a file from node_modules using fs? my module has a sample json file within, and uses fs.readFile(path) to load it, but cannot locate - is there a trick to this?

Thanks.


#2

Replace the path with “require.resolve(“akamai-nginx/sample.papi.json”)” and that will return what you want.

Thanks!

Francisco


#3

thanks! that worked. thought i had tried that :slight_smile: