node-cjson icon indicating copy to clipboard operation
node-cjson copied to clipboard

Does not work with relative paths in sub-directories

Open drywolf opened this issue 8 years ago • 1 comments

Hi,

I wanted to replace some of my require('./config.json') usages in my project with cjson.load('./config.json'). The config.json file is located in a sub-directory structure of my project, and alongside it there is a .js file that tries to require/load it.

But it turns out that cjson tries to resolve the relative path starting from the root of the project, not the current directory of the .js file. Is this algorithm for resolving relative paths by design for cjson, or is it supposed to work the same way as the default node.js require() algorithm ? (which I would have expected)

drywolf avatar Apr 20 '16 09:04 drywolf

Consider it as a bug. I will accept a pr for resolving path the way require does it.

kof avatar Apr 20 '16 09:04 kof