node. js method of reading a file to a string

  • 2020-06-22 23:47:39
  • OfStack

This article is an example of how node.js reads a file into a string. Share to everybody for everybody reference. The specific analysis is as follows:

Node.js is an JavaScript toolkit 1 adapted to write high-performance web servers, and the series 1 changes begin here. Uniquely, Node.js will assume that you are running it under POSIX Linux or Mac OS X.

The main codes are as follows:


var fs = require('fs');
var file = fs.readFileSync(path, "utf8");
console.log(file);

I hope this article is helpful for your ES20en.ES21en programming.


Related articles: