iOS下因為有watchman這個插件,所以啟動很快(npm start),而Windows下則非常慢,最要命的是遇到了修改js文件后,點擊reload居然一直是請求的緩存bundle,淚崩。。。
后來找到一篇文章,解決了這個問題,就是說超時導致的,但是超時的時候沒有反饋錯誤,原因不明。解決方案就是延長超時時間:
//\node_modules\node-haste\lib\FileWatcher\index.js
// 修改MAX_WAIT_TIME的值為360000
//找到如下代碼
key: '_createWatcher',
value: function _createWatcher(rootConfig) {
var watcher = new WatcherClass(rootConfig.dir, {
glob: rootConfig.globs,
dot: false
});
return new Promise(function (resolve, reject) {
var rejectTimeout = setTimeout(function () {
return reject(new Error(timeoutMessage(WatcherClass)));
}, MAX_WAIT_TIME);
watcher.once('ready', function () {
clearTimeout(rejectTimeout);
resolve(watcher);
});
});
}
//修改為
key: '_createWatcher',
value: function _createWatcher(rootConfig) {
var watcher = new WatcherClass(rootConfig.dir, {
glob: rootConfig.globs,
dot: false
});
return new Promise(function (resolve, reject) {
const rejectTimeout = setTimeout(function() {
reject(new Error([
'Watcher took too long to load',
'Try running `watchman version` from your terminal',
'https://facebook.github.io/watchman/docs/troubleshooting.html',
].join('\n')));
}, MAX_WAIT_TIME);
watcher.once('ready', function () {
clearTimeout(rejectTimeout);
resolve(watcher);
});
});
}
參考文章:[Android][0.24.1][Windows] packager not update when change js file content #7257