jprichardson / node-jsonfile

Easily read/write JSON files.
MIT License
1.2k stars 321 forks source link

autocreate folder doesnt work from Path-value #40

Closed WuglyakBolgoink closed 8 years ago

WuglyakBolgoink commented 8 years ago

Hi,

is it possible to create folders from path-value if this directory not exist?


function saveJsonInFile(jsonObject, pathToSave) {
    jsonfile.writeFileSync(pathToSave, jsonObject);
}

fs.js:584
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT: no such file or directory, open 'C:\workspace\demoNode\out2\chn.json'
jprichardson commented 8 years ago

Sure. See: https://www.npmjs.com/package/fs-extra#outputjson-file-data-options-callback for that.

Cyberider commented 8 years ago

perfect :+1:

openjck commented 7 years ago

Updated link: https://www.npmjs.com/package/fs-extra#outputjsonfile-data-options-callback