在Windows下好不容易安裝好React Native環境之后,運行npm start,結果就是無限被等待,快的話160秒(將近3分鍾啊。。。。)
而Mac下因為有watchman所以是飛一樣的速度,1秒不到,一般幾十到幾百毫秒。此處一千一萬只草泥飛在胸中奔騰…
所幸找到一個解決方案了,能讓npm start也飛起來(500毫秒左右),操作步驟如下:
1、安裝watchman,在Windows下暫時處於alpha版本但是可以使用,是一個zip包 https://facebook.github.io/watchman/docs/install.html | http://bit.ly/watchmanwinalpha
2、添加解壓后的watchman到系統環境變量path中,如果成功的話, win + r輸入 watchman -v應該返回的是3.7.0
3、右擊項目svn目錄,取消目錄權限為只讀,否則會報錯,錯誤如下
[Hot ;Module Replacement] Server listening on /hot
React ;packager ready.
Failed ;to build DependencyGraph: Watchman error: query failed: synchronization failed: Permission denied. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
Error: ;Watchman error: query failed: synchronization failed: Permission denied. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
; at /Users/Ali/Desktop/app/Test/node_modules/react-native/node_modules/node-haste/lib/crawlers/watchman.js:63:11
at process._tickCallback (node.js:368:9)
現在再來看看npm start的速度,Windows也能飛起來了^_^
參考stackoverflow上的帖子,它給出的是Mac下的方案,使用chmod 777來修改權限為讀、寫、刪,對應Windows下我懷疑是只讀,所以試了一下取消只讀,居然可以了
鑒於bit.ly被牆,這里我將watchman.zip上傳到了博客園,可以
點擊這里直接下載>>