fs.writeFile not showing changes?

So basically when i make a change/create a file with fs.writeFile the changes aren’t showing in the editor. Is this an error? Because if not it would be great if you added that so i dont have to type in ‘refresh’ all the time in the terminal.

There is no way to update the edutor wuthout running refresh in the terminal. However, you can view any file by running cat filename in the terminal.

5 Likes

You could use fs.watchFile to watch changes in the file.
You can do this by using:

fs.watchFile('./you/path/to/file', (filename) => {
 // unfortuantelywatchfile doesn't return the file content.
 // but you can read it by using readfile again.
fs.readfile('your/path/to/file/again', 'utf-8', (err, data) => {
    if err throw err;
    return;
    console.log(data); // the changes...   
})
})

Hope this helps!!!