I am trying to read the contents of a properties file in node. this is my call:
fs.readFile(\"server/config.properties\", {encoding: \'utf8\'}, function(err, dat
Depending on the version of Node you're running, the argument may be just the encoding:
fs.readFile("server/config.properties", 'utf8', function(err, data ) {
console.log( data );
});
The 2nd argument changed to options with v0.10:
- FS
readFile(),writeFile(),appendFile()and their Sync counterparts now take anoptionsobject (but the old API, anencodingstring, is still supported)
For former documentation:
You should change {encoding: 'utf8'} to {encoding: 'utf-8'}, for example:
fs.readFile("server/config.properties", {encoding: 'utf-8'}, function(err, data ) {
console.log( data );
});