node read file
// load fs
const fs = require("fs");
// read the file
const content = fs.readFileSync("./my_file.txt");
// print it
console.log(content.toString());const fs = require("fs");
// __dirname means relative to script. Use "./data.txt" if you want it relative to execution path.
fs.readFile(__dirname + "/data.txt", (error, data) => {
if(error) {
throw error;
}
console.log(data.toString());
});var content;
fs.readFile('./Index.html', function read(err, data) {
if (err) {
throw err;
}
content = data;
});
console.log(content);fs = require('fs')
fs.readFile('/etc/hosts', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
console.log(data);
});
Also in JavaScript:
- js date in two weeks
- how to deploy angular site firebase
- deploy react app netlify
- chrome extension get current tab from popup
- javascript hwo to return largest value with index
- how to create click function in javascript
- javascript group array of objects lodash
- popper.min.js download
- how to add script before </body> in magento 2
- javascript bigint
- express example using puppeteer
- remove from set javascript
- javascript loop object
- how to select a class and then change the children of that class with javascript
- truthy and falsy values in javascript
- how to find out what a string ends with in javascript
- how to iterate through an object in javascript
- program to parenthesize an expression
- string to query string javascript
- js revers string fucntion
- how to remove an class in javascript
- react client real ip address
- set dynamic route in link react js
- could not find a declaration file for module in react project