You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
process.cwd() throws when the current directory does not exist.
Error: ENOENT: no such file or directory, uv_cwd
at process.wrappedCwd [as cwd] (node:internal/bootstrap/switches/does_own_process_state:138:28) {
errno: -2,
code: 'ENOENT',
syscall: 'uv_cwd'
}
child_process.spawn() also throws when the cwd option's directory does not exist.
Error: spawnSync echo ENOENT
at __node_internal_captureLargerStackTrace (node:internal/errors:563:5)
at __node_internal_errnoException (node:internal/errors:690:12)
... // 20 lines of stack trace
at TTY.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -2,
code: 'ENOENT',
syscall: 'spawnSync echo',
path: 'echo',
spawnargs: []
},
There are also other reasons which can make cwd fail such as missing file permissions, pointing to a non-directory, or using a file name too long (libuv uses getcwd on Unix and GetCurrentDirectory on Windows).
When the above problems happen, we should provide with better error messages. The current error messages are confusing as they do not always mention cwd, making it look like the issue is the command not existing. I have actually gotten this myself in the past, and it can lead to long debugging sessions before realizing what the problem is.
The text was updated successfully, but these errors were encountered:
ehmicky
changed the title
Error when cwd is missing
Better error message when cwd is invalid
Feb 8, 2024
process.cwd()
throws when the current directory does not exist.child_process.spawn()
also throws when thecwd
option's directory does not exist.There are also other reasons which can make
cwd
fail such as missing file permissions, pointing to a non-directory, or using a file name too long (libuv usesgetcwd
on Unix andGetCurrentDirectory
on Windows).When the above problems happen, we should provide with better error messages. The current error messages are confusing as they do not always mention
cwd
, making it look like the issue is the command not existing. I have actually gotten this myself in the past, and it can lead to long debugging sessions before realizing what the problem is.The text was updated successfully, but these errors were encountered: