Node: fs.watch not work in win10 Bash.

Created on 30 Jun 2016  Â·  10Comments  Â·  Source: nodejs/node

win10 provides developers with a familiar Bash environment.
I'm try to use node in win10 Bash,fs.watch not work ,throw EPERM exception.
fs.watchFile is ok.

node version : v6.2.1. (Linux Binaries)
window version : windows 10 insider preview 14366
linux subsystem version : Linux DESKTOP-RNI52ML 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux

test file

test.js

var path = require('path');
fs.watch('/home/li/app1/', function(event) {
console.info(event)
})

exception :

fs.js:1425
throw error;
^
Error: watch /home/li/app1/ EPERM
at exports._errnoException (util.js:1007:11)
at FSWatcher.start (fs.js:1423:19)
at Object.fs.watch (fs.js:1450:11)
at Object. (/mnt/c/Users/li/git/portal/integration_fe/test.js:4:4)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)

Windows Subsystem for Linux (WSL) windows

Most helpful comment

I did some tweets and hopefully they made it it to Microsoft to do list, hopefully the high priority list hehe

All 10 comments

I suspect the Linux subsystem doesn't implement inotify yet or puts some restraints on it. Almost certainly not a bug in node.js.

I just wrote a cpp program to test inotify api , the inotify_add_watch return -1 , not work.
I've completed a feedback to MS Insider Program.

thank you!

Thanks, I'll close out the issue.

I did some tweets and hopefully they made it it to Microsoft to do list, hopefully the high priority list hehe

I found best way to notify microsoft the importance of fixing this issue. Vote here: support-for-filesystem-watchers-like-inotify Currently it's # 5!

also Windows Subsystem For Linux (WSL) User Voice main page

and Github page for reporting issues

and Github WSL Issue for this issue

This should now work in Windows 10 Insider builds >= 14942

@bitcrazed I have just singup for Insider Preview Builds in windows settings, and installed updates after it, but my build is 14393 (in System Information). Is it correct? Am I able to get higher builds?

@bitcrazed I have just singup for Insider Preview Builds in windows settings, and installed updates after it, but my build is 14393 (in System Information). Is it correct? Am I able to get higher builds?

@whitecolor, Windows Creator Update was released you should be able to get Microsoft Windows [Version 10.0.15063] easily - https://blogs.windows.com/windowsexperience/?p=144461

I can confirm it works with node v7.8.0 on Microsoft Windows [Version 10.0.15063]
P.S. c:\code in a symlink to d:\code hence /mnt/c/code == /mnt/d/code

var fs = require('fs');                         
fs.watch('/mnt/d/code/4node', function(event) { 
  console.info('/mnt/d/code/4node')             
  console.info(event)                           
})                                              

fs.watch('/home/refael', function(event) {      
  console.info('/home/refael')                  
  console.info(event)                           
})                                              
refael@refaelux:/mnt/d/code/4node$ node test-7496.js
refael@refaelux:~$ touch test.test
/home/refael
rename
/home/refael
change
refael@refaelux:/mnt/c/code/4node$ touch test.test
/mnt/d/code/4node
rename
/mnt/d/code/4node
change
/mnt/d/code/4node
change
refael@refaelux:/mnt/d/code/4node$ rm test.test
/mnt/d/code/4node
rename
/mnt/d/code/4node
rename
/mnt/d/code/4node
rename

@refack uh yes thanks for the tip)

Was this page helpful?
0 / 5 - 0 ratings