0

I'm using fs module to log my node.js app, and I don't find on google how to do a linebreak with fs for a text file...

I've tried some fs.append with nothing in it and it just doesn't make anything.

Thanks in advance, ~TBD

EDIT : I'm using .txt file to enable fast log reading...

TheBlackDev_
  • 93
  • 10
  • 3
    @t.niese Windows is `\r\n`. Old, old Mac was `\r`. In any case, you should use the `EOL` constant from `os`. See also: https://stackoverflow.com/a/14063413/362536 – Brad Jan 01 '19 at 18:23

1 Answers1

1

It would be great to have some sample code to show for further help, but normally the code would look like this:

//Suggesting you are using ES6, if not, change all 'const' to 'var'

const fileSystem = require('fs');

//Change the data below, the path and data, but not the \n. There might be problems when using \n, if it occurs, consider changing it to \r.
fileSystem.writeFileSync('./path/to/your/file.txt', 'yourdata\n');

See: \n or \r

Masternode
  • 26
  • 4