I would like to change the file owner of a Node.js-written file. I think there is no way to set the owner directly during file write (or maybe there's a way not documented?). Is there a way to change the owner afterwards?
My Node.js app runs in a docker container under the root user. So all files written by Node.js are owned by root. I want to set the owner to www-data, for example. Is it possible?
You could use the fs module:
fs.chown(path, 1,1, console.log);
Though this presumes you know the uid and gid of www-data (user) and www-data (group).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With