fs.chmod(path, mode, callback)


异步更改文件的权限。完成回调不会提供除可能的异常以外的任何参数。

【Asynchronously changes the permissions of a file. No arguments other than a possible exception are given to the completion callback.】

有关更多详细信息,请参阅 POSIX chmod(2) 文档。

【See the POSIX chmod(2) documentation for more detail.】

import { chmod } from 'node:fs';

chmod('my_file.txt', 0o775, (err) => {
  if (err) throw err;
  console.log('The permissions for file "my_file.txt" have been changed!');
});