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):
error: Uncaught Error: Input watch path is neither a file nor a directory.
at new FsWatcher (ext:runtime/40_fs_events.js:17:21)
at Object.watchFs (ext:runtime/40_fs_events.js:60:10)
at ext:deno_node/_fs/_fs_watch.ts:58:21
at Object.action (ext:deno_web/02_timers.js:151:11)
at handleTimerMacrotask (ext:deno_web/02_timers.js:65:10)
at eventLoopTick (ext:core/01_core.js:189:21)
error: Uncaught Error: Input watch path is neither a file nor a directory.
at new FsWatcher (ext:runtime/40_fs_events.js:17:21)
at Object.watchFs (ext:runtime/40_fs_events.js:60:10)
at ext:deno_node/_fs/_fs_watch.ts:58:21
at Object.action (ext:deno_web/02_timers.js:151:11)
at handleTimerMacrotask (ext:deno_web/02_timers.js:65:10)
at eventLoopTick (ext:core/01_core.js:189:21)
I'm not able to diagonise the error, google has nothing about it and I dont use the watch functionality. The run command was:
deno run --allow-read --allow-env --allow-net --allow-sys index.ts
deno run --allow-read --allow-env --allow-net --allow-sys index.ts
7 Replies
Deno AI Helper
Deno AI Helper10mo ago
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.
Leokuma
Leokuma10mo ago
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?
ⴷMOUR
ⴷMOUR10mo ago
@Joshua | Rem-Chan ^^
NDH
NDH10mo ago
Or a hard coded slash issue '/' vs '\'.
Joshua | Rem-Chan
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:
{
"@discordeno/bot": "^19.0.0-next.8d1ba2a",
"@spectacles/brokers": "^0.9.3",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"ioredis": "^5.3.2",
"winston": "^3.9.0"
}
{
"@discordeno/bot": "^19.0.0-next.8d1ba2a",
"@spectacles/brokers": "^0.9.3",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"ioredis": "^5.3.2",
"winston": "^3.9.0"
}
marvinh.
marvinh.10mo ago
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
Joshua | Rem-Chan
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