ENOENT using fs.appendFile()

Mimetix

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?

alandarev

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ENOENT error when using fs.writeFile

From Dev

Using fs.readdir returns ENOENT on vps, but not on localhost

From Dev

fs.appendFile returning [object Object]

From Dev

Using fs.readdir and fs.statSync returns ENOENT, no such file or directory error

From Dev

Exit Node Process After Successful fs.appendFile

From Dev

Cannot create file with Node.js fs.appendFile

From Dev

ENOENT, no such file or directory on fs.mkdirSync

From Dev

ENOENT: no such file or directory writing file with fs

From Dev

NodeJS: Does fs.appendFile keeps a link to the file open so appends are faster?

From Dev

NodeJS: Does fs.appendFile keeps a link to the file open so appends are faster?

From Dev

Why does my NodeJS script bog down during fs.readFile and fs.appendFile handling large numbers of files.

From Dev

Using 'fs' with browserify

From Dev

Using fs.stat and fs.writeFile

From Dev

Mock fs module using mockery

From Dev

Using fs.open and fs.write to write exclusively to a file

From Dev

Node.js: Error: spawn ENOENT while using GM module

From Dev

Using Promises with fs.readFile in a loop

From Dev

How to suppress awk output when using FS?

From Dev

Not able to read the file using fs nodejs

From Dev

Writing into file in nodejs using fs.writefilesync

From Dev

How to refactor Node.js code that uses fs.readFileSync() into using fs.readFile()?

From Dev

How to refactor Node.js code that uses fs.readFileSync() into using fs.readFile()?

From Dev

Node appendFile not appending data chunk to file on filesystem

From Dev

nodeJS: using (fs) to try and access a static resource but receive 404 error?

From Dev

using a wildcard/glob/minimatch in an fs.readFile (inside express app)

From Dev

How to check if a file or directory exists without using fs.exists?

From Dev

How to copy data from HDFS to Local FS using oozie workflow?

From Dev

Editing Docker container FS using Atom/Sublime-Text?

From Dev

Uploading document in NodeJs using Fs module : Error: write after end

Related Related

  1. 1

    ENOENT error when using fs.writeFile

  2. 2

    Using fs.readdir returns ENOENT on vps, but not on localhost

  3. 3

    fs.appendFile returning [object Object]

  4. 4

    Using fs.readdir and fs.statSync returns ENOENT, no such file or directory error

  5. 5

    Exit Node Process After Successful fs.appendFile

  6. 6

    Cannot create file with Node.js fs.appendFile

  7. 7

    ENOENT, no such file or directory on fs.mkdirSync

  8. 8

    ENOENT: no such file or directory writing file with fs

  9. 9

    NodeJS: Does fs.appendFile keeps a link to the file open so appends are faster?

  10. 10

    NodeJS: Does fs.appendFile keeps a link to the file open so appends are faster?

  11. 11

    Why does my NodeJS script bog down during fs.readFile and fs.appendFile handling large numbers of files.

  12. 12

    Using 'fs' with browserify

  13. 13

    Using fs.stat and fs.writeFile

  14. 14

    Mock fs module using mockery

  15. 15

    Using fs.open and fs.write to write exclusively to a file

  16. 16

    Node.js: Error: spawn ENOENT while using GM module

  17. 17

    Using Promises with fs.readFile in a loop

  18. 18

    How to suppress awk output when using FS?

  19. 19

    Not able to read the file using fs nodejs

  20. 20

    Writing into file in nodejs using fs.writefilesync

  21. 21

    How to refactor Node.js code that uses fs.readFileSync() into using fs.readFile()?

  22. 22

    How to refactor Node.js code that uses fs.readFileSync() into using fs.readFile()?

  23. 23

    Node appendFile not appending data chunk to file on filesystem

  24. 24

    nodeJS: using (fs) to try and access a static resource but receive 404 error?

  25. 25

    using a wildcard/glob/minimatch in an fs.readFile (inside express app)

  26. 26

    How to check if a file or directory exists without using fs.exists?

  27. 27

    How to copy data from HDFS to Local FS using oozie workflow?

  28. 28

    Editing Docker container FS using Atom/Sublime-Text?

  29. 29

    Uploading document in NodeJs using Fs module : Error: write after end

HotTag

Archive