I\'m trying to create a full path if it doesn\'t exist.
The code looks like this:
var fs = require(\'fs\'); if (!fs.existsSync(newDest)) fs.mkdirSync
A more robust answer is to use use mkdirp.
var mkdirp = require('mkdirp'); mkdirp('/path/to/dir', function (err) { if (err) console.error(err) else console.log('dir created') });
Then proceed to write the file into the full path with:
fs.writeFile ('/path/to/dir/file.dat'....