FS not working?

Hey, for my project I’m using FS, to save files, and write data into it, but for some reason when i restart my project my data gets refreshed to the old data like its never being saved, I’m sure that my fs is working and setup correctly, (its working localy) also when I check the files they have never been updated? and the file still looks the same.

Running refresh in the console should re-sync the editor and your project console.

This indeed works, thanks but is there away this is done automatically?

No. You have to manually re-sync the editor. You could make your code run the refresh command every so often. However, the refresh command also restarts your project.

Thats fine, how could i do this?

Open the Glitch Console:

  1. Click on Tools button on the bottom left in the project editor.
  2. Click on Logs.
  3. The logs will be shown at the bottom and above the logs there will be a button called Console. Click on it.
  4. Then run the command refresh.

I ment how can I make it run the refresh command automaticly?

Like XxProGamerxX said.

@charliea21, it’s not safe to run refresh command using the code, because it can result in a refreshing loop.

I have code which does force refresh every minute and it doesn’t get stuck in a loop.

Oh, you’re running the command for a specific event?

How did u make this refresh command?

This is how I did it:

const { exec } = require("child_process");

exec("refresh", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
});

DO NOT RUN THIS IN YOUR SERVER.JS AS BASE CODE AS IT MAY RESULT IN A FOREVER REFRESH LOOP, at least it did for me.

It might if you ain’t careful…

so beware

Hey hhalby786,

thank you for your Code!

Where I should place the code in server.js precise, so it don’t get in a forever loop?

Or

hi, i’d advise against using programmatic refreshing of glitch containers like young me mentioned above, because when you add the code, glitch will run server.js and refresh it, which causes glitch to run server.js again, and refreshes the project again, which causes glitch to run server.js again and so on, you get the idea.