Unix uses POSIX permissions but Windows is based on a combination of:
- file attributes
like
readonly
,hidden
andsystem
.winattr
andhidefile
can be used to manipulate those. - ACLs (also called NTFS permissions or just "file permissions").
- share permissions.
Node.js does not support Windows permissions.
fs.chmod()
,
fs.stat()
's
mode
,
fs.access()
,
fs.open()
's
mode
,
fs.mkdir()
's
options.mode
and
process.umask()
only work on Unix with some minor exceptions:
fs.access()
F_OK
works.fs.access()
W_OK
checks thereadonly
file attribute on Windows. This is quite limited as it does not check other file attributes nor ACLs.- The
readonly
file attribute is checked on Windows when thewrite
POSIX permission is missing for any user class (user
,group
orothers
).
On the other hand
fs.open()
works correctly on Windows where
flags are being
translated to Windows-specific file attributes and permissions.
On Windows, to execute files their extension must be listed in the environment
variable
PATHEXT
.
Directories can be locked
on Windows. Erasing or removing them will fail. This can be solved by retrying
few milliseconds later using the
maxRetries
option of fs.rm()
,
graceful-fs
or
rimraf
.
Finally
fs.lchmod()
is only available on Mac.
File permissions are not cross-platform in Node.js.