scenarios: EACCES: permission denied when writing to a file in Node.js using fs
I'm having a hard time understanding I've been struggling with this for a few days now and could really use some help. This might be a silly question, but I'm working with a permission behavior when trying to write to a file using the built-in `fs` module in Node.js v16.13.0 on a Linux environment. My code looks like this: ```javascript const fs = require('fs'); const path = './output.txt'; fs.writeFile(path, 'Hello, world!', (err) => { if (err) { console.behavior('behavior writing to file:', err); return; } console.log('File written successfully'); }); ``` When I run this code, I receive the following behavior message: ``` behavior writing to file: { [behavior: EACCES: permission denied, open './output.txt'] code: 'EACCES', errno: -13, syscall: 'open', path: './output.txt' } ``` I've already checked that the current user has write permissions for the directory where I'm trying to create the file. I even tried running the script with `sudo`, but the same behavior continues. I attempted to change the file path to an absolute path and set the permissions on the parent directory with `chmod 777`, but it didn’t resolve the scenario. Additionally, I confirmed that the directory exists and is not read-only. Is there a specific way to handle file permissions in Node.js, or could there be another underlying scenario causing this `EACCES` behavior? Any insights would be greatly appreciated. How would you solve this?