Search code examples
node.jsubuntufs

File Creation on Nodejs without CRLF line terminators


I have two identical files when I compare them as string. But sizes are different and filetytes are also different when I ask it like below.

$ file ~/Desktop/gprs
ASCII text

$ file ~/Desktop/2/gprs
ASCII text, with CRLF line terminators

I created first one with Ubuntu > New Document > Empty Document section.
I created second file from NodeJs with fs plugin like below :

fs.writeFile("/2/gprs", data, function(error) {

      if (error) {

        console.log(error);

      } else {

        console.log("Ok");
      }
});

I want second file without CRLF line terminators option. How can I create it with that way ?

Thanks


Solution

  • var os = require('os'); os.EOL solved my problem