ENOENT using fs.appendFile()

I am trying to append data into some files.

Docs says fs.appendFile:

Asynchronously append data to a file, creating the file if it not yet exists, data can be a string or a buffer

function appendData(products) {
var productsPromises = products.map(function(product) {
    var title = product['title'];
    return fs.appendFile('/XXXXX/' + title, product, 'utf8', function(err){
        console.log(err);
    });
});
return Promise.all(productsPromises);
}

I am getting Error:

ENOENT, open '/XXXXX/PPPPPPPP'

What am i doing wrong?

You might have accidently added / in front of XXXXX.

I you expect it to write to a folder XXXXX which is located in the same place of where you launched the application, then change your code to:

return fs.appendFile('XXXXX/' + title, product, 'utf8', function(err){

As / In front means root of your filesystem, and the error is common of path does not exist. I.e. there is no XXXXX in root of your filesystem, as @Rahil Wazir said.

The problem was that i forgot to add the dot.

Should be:

return fs.appendFile('./XXXXX/' + title, product, 'utf8', function(err){