error: Uncaught Error: Input watch path is neither a file nor a directory.
Im encountering a weird error when I run a code in Windows that was initially created in a OSX.
It still runs fine in OSX, but in windows its shows the following error (synced through github):
I'm not able to diagonise the error, google has nothing about it and I dont use the watch functionality.
The run command was:
7 Replies
The error message you're seeing is related to the
Deno.watchFs
function. According to the documentation, this function is used to watch for file system events against one or more paths, which can be files or directories. The error message "Input watch path is neither a file nor a directory" suggests that the path you're trying to watch does not exist or is not recognized as a file or directory.
The issue might be due to differences in how file paths are handled in different operating systems. For example, Windows uses backslashes (\
) in file paths, while macOS and Linux use forward slashes (/
). If your code includes file paths, you might need to adjust them to be compatible with Windows.
If you're not explicitly using Deno.watchFs
in your code, it might be used by a library or module that your code depends on. You could try to identify where Deno.watchFs
is used and what paths it's watching.
If you're unable to find the source of the issue, you could try to debug the problem by adding console.log
statements before the Deno.watchFs
calls to print out the paths that are being watched. This might help you identify any paths that could be causing the issue.
Remember that Deno.watchFs
requires allow-read
permission, which you have already included in your run command.
Please note that this advice is general in nature and not explicitly stated in the documentation.Maybe one of your dependencies (an npm dependency I'm guessing) is trying to watch a file or directory that you have in OSX but you don't have in Windows. Also maybe when you added that dependency it detected that the OS was OSX and configured itself to run in it and now it can't run in Windows?
@Joshua | Rem-Chan ^^
Or a hard coded slash issue '/' vs '\'.
but the node_modules aren't transferred while sharing the code right? So when its run on the windows, it shouldnt affect it
The program doesnt even go to the first line, and thats weird. Like we added console.log on top of everything to see if its executed but nope. The run goes straight to the error.
the npm packages we use are:
Please file a bug for that. It sounds like something the team should be aware of and can resolve in CLI so that other user's don't run into this
Looks like its the npm i18n package doing its work. It has a
fs.watch
in it, and thats the trigger I believe. I dont exactly know why it should but yeah. Removing it fixed the issue.
It works fine in mac but not in windows