回答我自己的问题。这个帖子 https://github.com/facebook/react-native/issues/7257帮助过我。
在此文件 \node_modules\react-native\node_modules\node-haste\lib\FileWatcher\ 内index.js
- 我必须增加
MAX_WAIT_TIME
(我的我从120000改成了360000)。
- 也不得不改变
This
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);
});
});
}
into
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);
});
});
}
现在,在此更改之后,我所做的任何代码更改,我什至不必按 R 两次,它会自动更改。我希望这可以帮助像我这样的菜鸟。谢谢。