1const fs = require("fs");
2
3// __dirname means relative to script. Use "./data.txt" if you want it relative to execution path.
4fs.readFile(__dirname + "/data.txt", (error, data) => {
5 if(error) {
6 throw error;
7 }
8 console.log(data.toString());
9});