node-which
node-which copied to clipboard
[BUG] EACCES Error with Windows 11 App Execution Aliases
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
The node-which module (and its dependency isexe) encounters EACCES: permission denied errors when checking Windows 11 App Execution Aliases like mspaint.exe located in %LOCALAPPDATA%\Microsoft\WindowsApps\.
Error: EACCES: permission denied, stat 'C:\Users\username\AppData\Local\Microsoft\WindowsApps\mspaint.exe'
at statSync (node:fs:1740:25)
at t.statSync (node:electron/js2c/node_init:2:5407)
Windows 11 App Execution Aliases are special files that:
- Appear as regular
.exefiles in directory listings - Can be executed normally from command line
-
Cannot be accessed with
fs.stat()orfs.statSync()- these operations throwEACCESerrors -
Can be checked for existence using
fs.access()
- The
whichmodule correctly returnsnullwhen using{ nothrow: true } - The
isexemodule correctly returnsfalsewhen using{ ignoreErrors: true } - Direct
fs.statSync()calls fail withEACCES -
fs.accessSync()works correctly on the same files
Expected Behavior
Since mspaint.exe is a valid executable in the user's PATH that can be launched successfully, the expected behavior should be:
-
which.sync('mspaint')should return the path to the executable:C:\Users\username\AppData\Local\Microsoft\WindowsApps\mspaint.exe -
isexe.sync(mspaintPath)should returntrue(indicating the file is executable) - App Execution Aliases should be treated as valid executables since they:
- Have executable file extensions (
.exe) - Are included in the system PATH
- Can be launched successfully from command line
- Are legitimate Windows applications
- Have executable file extensions (
Steps To Reproduce
- Windows 11 system
- Node.js installed
-
whichmodule installed (npm install which) - MS Paint available as App Execution Alias (default on Windows 11)
const which = require('which');
const result = which.sync('mspaint');
console.log('Found mspaint at:', result);
Environment
- npm: 11.4.2
- Node: 22.15.0
- OS: Windows 11
- platform: Win32
The PR: https://github.com/isaacs/isexe/pull/40