Issue with node detecting the .data dir


I’m working on a project that I want to work on both glitch and a local environment. The issue I’m having is detecting the .data dir using fs, specifically this code.

    let dir = "../.data";
    !fs.existsSync(dir) && fs.mkdirSync(dir);

    let filepath = dir + "/keystore.json";
    fs.writeFileSync(filepath, data);

This runs in a subdirectory, like backend/utils.js, so that is why the “…/” is needed.

I have it working locally on my PC; however, on glitch this gives me an EACCES error.

Can anyone help?


Most likely you’re trying to listen on an unsupported port.

Should listen to

app.listen(process.env.PORT, ...


It sounds like the path to the file is incorrect. I’d suggest specifying a direct path rather than a relative one. Use __dirname+’/.data/keystore.json’ instead.


This helped solve the issue, Thank you!