React-native: [Android][0.24.1][Windows] packager not update when change js file content

Created on 27 Apr 2016  路  26Comments  路  Source: facebook/react-native

after i update react native to 0.24.1, I modify javascript code and save but packager server not detect this change. So reload js from my android have no effect.

anybody has some advance, thank very much.

Locked

Most helpful comment

at last . I found problem.

problem still is timeout . but when timeout it not show message for us (still don't know why.).

to solve this problem.

in file "node_modulesnode-hastelibFileWatcherindex.js"
you should increase "MAX_WAIT_TIME" variable (example : 360000) ;

and change function "_createWatcher"
from

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);
        });
      });
    }

to

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);
        });
      });
    }

now . every thing run normal . :D

All 26 comments

Have you tried restarting you packager/emulator/computer? Maybe check this issue: https://github.com/facebook/react-native/issues/306. Look at watchman, auto-saving.

restart packager , computer have no effect. i have no idea with this

+1, I got the same problem, live load and hot load both not working.
The js file only transformed once when I start the packager.
It also toke so long time to finish. here is the log :

[11:52:39] request:/index.android.bundle?platform=android&dev=true&hot=t
rue&minify=false
[11:52:39] find dependencies
[11:56:49] Crawling File System (261278ms)
[11:56:49] Building in-memory fs for JavaScript
[11:56:51] Building in-memory fs for JavaScript (1743ms)
[11:56:51] Building in-memory fs for Assets
[11:56:52] Building in-memory fs for Assets (1166ms)
[11:56:52] Building Haste Map
[11:56:53] Building (deprecated) Asset Map
[11:56:53] Building (deprecated) Asset Map (307ms)
[11:56:53] Building Haste Map (758ms)
[11:56:53] Building Dependency Graph (264980ms)
transformed 528/528 (100%)
[11:56:59] find dependencies (260047ms)
[11:56:59] request:/index.android.bundle?platform=android&dev=true&hot=t
rue&minify=false (260291ms)
[Hot Module Replacement] Client connected

at last . I found problem.

problem still is timeout . but when timeout it not show message for us (still don't know why.).

to solve this problem.

in file "node_modulesnode-hastelibFileWatcherindex.js"
you should increase "MAX_WAIT_TIME" variable (example : 360000) ;

and change function "_createWatcher"
from

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);
        });
      });
    }

to

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);
        });
      });
    }

now . every thing run normal . :D

great solution InnerPeace080:+1:

Thanks a lot, PeaceFromInside080 !!! ^_^

How to deal with Windows Platform?
"node-hastelibFileWatcherindex.js" how can I get this file ?install watchman?

finally got the file path :node_modulesreact-nativenode_modulesnode-haste

thanks

thanks, that's work.

I was stuck with this one for hours. @InnerPeace080 your solution saved my life! Amazing! :)

You saved my day. Your solution works perfect. Thank you so much !!!!

For the benefit of future Googlers, MAX_WAIT_TIME is located here :

node_modulesreact-nativepackagerreact-packagersrcnode-hasteFileWatcher

Thank you very much @InnerPeace080! I was stucked in this for hours!

Thank you all From the bottom of Stavro's heart!

thanks!

update node.js to 6.x may works

Thank you @InnerPeace080 . On my windows system file path was :node_modulesreact-nativepackagerreact-packagersrcnode-hasteFilewatcher.

This not good. The code is now like this. Error come up when I do replace

`_createWatcher(rootConfig) {
const watcher = new WatcherClass(rootConfig.dir, {
glob: rootConfig.globs,
dot: false,
});

return new Promise((resolve, reject) => {
  const rejectTimeout = setTimeout(
    () => reject(new Error(timeoutMessage(WatcherClass))),
    MAX_WAIT_TIME
  );

  watcher.once('ready', () => {
    clearTimeout(rejectTimeout);
    resolve(watcher);
  });
});

}`

Niccee!!!! Thank You !!!!

@neilhanekom I'm in the process of testing this myself, but you can still change the pertinent value MAX_WAIT_TIME to the new value. Scroll up to where that const is declared.

EDIT

Totally still works, you don't have to replace the entire function, just change the value of the const.

I could not find node-haste folder in my node_modules folder.

I could not find FileWatcher in my folder

I gave my hours in finding FileWatcher in my folder but couldn't find. But anyways, in my case, the problem due to which my app wasn't updating on js fiile change is that somehow, using "npm run anroid" command, my app was by default running in production mode (that I came to know from cmd prompt). Then I restarted my system and things started working fine.

My Problem was the following:
I think trough executing
"react-native bundle --platform android --dev true --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res"
i edited the BuildConfig.class from react-native and then i had to build the whole project another time and execute "react-native run-android" to see the changes every time.

I solved the problem through overriding the BuildConfig.class from:

public final class BuildConfig {
public static final boolean DEBUG = false;
public static final String APPLICATION_ID = "com.facebook.react";
public static final String BUILD_TYPE = "release";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
public static final int EXOPACKAGE_FLAGS = 0;
public static final boolean IS_INTERNAL_BUILD = false;

public BuildConfig() {
}

}

to:

public final class CustomBuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.xxx";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}

I have this problem too, my react native version is 0.54.0, i restarted my system like rastogitech do, then it work fine...

Was this page helpful?
0 / 5 - 0 ratings