Error: EACCES: permission denied


I’m having an issue, my express application can’t write files, this only happens in another .js file I use as a ‘code library’ for commands for my discord bot, when it tries to writeFile in the code library (which uses module.exports = {} to make sure other scripts can use the functions), it pops up an error that I can’t figure out.


{ Error: EACCES: permission denied, open '../serverdata.json'
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '../serverdata.json' }

For any glitch staff, the project name is aegis if you want to check it out


Hi @AquaticFish, I think this is probably due to what the location the relative path you’re using actually resolves to - I suspect you’re ending up trying to write to a file location that Node doesn’t have permissions to write to.

You could try using __dirname to create your path relative to the script the command is running in. Or you could try using an absolute path, since all Glitch applications run in the /app directory if you wanted your file to end up there you could use /app/serverdata.json.

Hope this helps!