Thursday, 7 June 2018

question about paths and published modules

So I made a node module that among other things has a src/ folder, on which a js file references a certain external json file.Said json file is in a different folder than the code calling it, and it is opened using s.readFileSync('../anotherfolder/myfile.json').To clarify, the folder structure would be something likesrc/ mycode.js anotherfolder/ myfile.son The code works, but after I publish the package, the relative route stops working. I'm assuming that this is due to the relative path being calculated in a different manner now? if so, how can I set it so that it works both in the project itself and as a module?

Submitted June 07, 2018 at 04:26PM by kace91

No comments:

Post a Comment