Answers for "node fs load file"

3

node load file

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());
});
Posted by: Guest on May-25-2020
3

node.js import fs

import fs from "fs";
Posted by: Guest on September-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language