Repository navigation
fs.access() not reporting error on Windows #19192
Description
Activity
- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.
on Mar 7, 2018 See #7700 ,
fs.accessdoes not check ACL on WindowsSetting a doc label because the documentation seems to be misleading:
fs.constants.R_OK - path can be read by the calling process.
fs.constants.W_OK - path can be written by the calling process.- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.
on Mar 7, 2018 Also cc @bnoordhuis is that a wont-fix on Windows?
This can be probably fixed in libuv, there is AccessCheck function in WinAPI that seems to do just that. For now lets just document this.
This can be probably fixed in libuv
I don't know if we should (but I also don't know if we shouldn't); we don't check ACLs on other platforms.
Not all platforms use ACLs as their native permissions mechanism. Ignoring ACLs makes
fs.access()essentially useless on Windows, and the function fails to do what it says it does:Tests a user's permissions for the file or directory specified by
path.Determining whether an ACL applies is a Hard Problem on many platforms. Doing it on one platform but not others makes it inconsistent. You're welcome to open a pull request but I expect other collaborators will raise the same concern.
I agree that this behavior makes
fs.accessuseless on Windows except for simply checking that a file/folder exists at all.As far as consistency is concerned, things are already inconsistent in behavior if
fs.accessworks as designed on one platform but not on another, so I don't see anything wrong with implementing platform-specific internals to create more consistency in the API behavior.- added a commit that references this issue
on Oct 19, 2018 - added a commit that references this issue
on Oct 24, 2018 - added 2 commits that reference this issue
on Nov 26, 2018 - added 2 commits that reference this issue
on Nov 28, 2018 - added a commit that references this issue
on Nov 29, 2018 Actually in 10.15.3 LTS, it does NOTHING, not even file existence check. I dont even have a D drive on my machine, and C:\dev does exist.
PS C:\Users\sc> node -e "const fs = require('fs'); fs.access('D:\\afsd', (err) => {console.log(``${err} is the error.``)})" is the error. PS C:\Users\sc> node -e "const fs = require('fs'); fs.access('C:\\dev', (err) => {console.log(``${err} is the error.``)})" is the error.I am having this exact issue. I am reading a directory's contents into an array, and getting the stat for each item. I attempted to use fs.access to filter out un-readable folders/files but it would not throw an error. I ended up using the error fs.stat provides to do my filtering. A janky solution, don't like it.
- added a commit that references this issue
on Jul 27, 2026
fs.access() returns no error when given a file/directory with no priveleges.
Code example:
Output: