React-native: Code change never showing up on reload (Hot reload not working either)

Created on 12 Nov 2016  ยท  18Comments  ยท  Source: facebook/react-native

Description

So I am following the sample app. This used to work on my old machine, but I moved to a new one and suddenly it's not working.

Seems like watchman is not detecting file changes anymore?

AwesomeProject โžœ npm run start

> [email protected] start /Users/jordan/Desktop/AwesomeProject
> node node_modules/react-native/local-cli/cli.js start

(node:372) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
(node:372) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
Scanning 709 folders for symlinks in /Users/jordan/Desktop/AwesomeProject/node_modules (4ms)
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  Running packager on port 8081.                                            โ”‚
 โ”‚                                                                            โ”‚
 โ”‚  Keep this packager running while developing on any JS projects. Feel      โ”‚
 โ”‚  free to close this tab and run your own packager instance if you          โ”‚
 โ”‚  prefer.                                                                   โ”‚
 โ”‚                                                                            โ”‚
 โ”‚  https://github.com/facebook/react-native                                  โ”‚
 โ”‚                                                                            โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Looking for JS files in
   /Users/jordan/Desktop/AwesomeProject

[Hot Module Replacement] Server listening on /hot

React packager ready.

[11/11/2016, 9:15:16 PM] <START> Initializing Packager
[11/11/2016, 9:15:16 PM] <START> Building in-memory fs for JavaScript
[11/11/2016, 9:15:16 PM] <END>   Building in-memory fs for JavaScript (193ms)
[11/11/2016, 9:15:16 PM] <START> Building Haste Map
[11/11/2016, 9:15:17 PM] <END>   Building Haste Map (600ms)
[11/11/2016, 9:15:17 PM] <END>   Initializing Packager (869ms)

I see the above when I run npm run start. If I make a change to index.ios.js and save it, nothing happens. And if I hit CMD-r the simulator reloads but my change does not appear unless I stop npm run start and run it again.

Reproduction

I just did this:

react-native init AwesomeProject
cd AwesomeProject
react-native run-ios

And then ran npm run start or even if I do react-native run-ios, same issue.

Additional Information

react-native-cli: 1.2.0
react-native: 0.37.0
node: v7.0.0
watchman: 4.7.0

  • Platform: ios and android
  • Operating System: MacOS Sierra.
Locked

Most helpful comment

Hey everyone. @leeight @RomualdPercereau @chanceeakin @bluefantasy728 Did some playing around and wasn't getting answers anywhere.

I did the following and it seems to be working now:

rm -rf /usr/local/var/run/watchman && brew uninstall watchman && brew install watchman

Hopefully that works for you!

All 18 comments

same issue

Bump.

Same problem, even when loading file with a browser with http://localhost:8081/index.ios.bundle

Change are not applied.

Although changes seems to be called :

[11/15/2016, 11:35:41 AM] <START> Requesting bundle  url: /index.ios.bundle?platform=ios&dev=true&minify=false  
[11/15/2016, 11:35:41 AM] <END>   Requesting bundle  url: /index.ios.bundle?platform=ios&dev=true&minify=false   (14ms)

+1

Hey everyone. @leeight @RomualdPercereau @chanceeakin @bluefantasy728 Did some playing around and wasn't getting answers anywhere.

I did the following and it seems to be working now:

rm -rf /usr/local/var/run/watchman && brew uninstall watchman && brew install watchman

Hopefully that works for you!

@Jonovono: It worked!!!

You're the hero we need, not the one we deserve.

@Jonovono it works! Thank you!

@Jonovono Thank you it worked! I just spent 3 days trying to solve this issue!

@Jonovono well It worked.
I just wanted to add some Points

  1. Initially I was deleting the folder
    /usr/local/var/run/watchman/$USER-state
    which is not giving me desired result.

    1. Watchman does not detect changes in the folder where .lock file is present.
      There is a yarn.lock file which is generated when we are installing yarn thus we have to remove that lock file. And, no need to uninstall and install watchman in my Case.

Thank You @Jonovono

Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why.

Well I just removed yarn.lock and now its working fine.

npm install --save-dev react-native-cli
sIMPLY use this

Simply restarting the packager worked for me

I have a this problem as well, all to the sudden. Nothing of the above worked. I'm wondering, it is possible to force a rebuild the JS files without doing an XCode clean?

None of the above-mentioned solutions are working for me.

Me neither. On OSX, and that's a first, the only thing that could fix this for me out was to reboot, believe it or not. I'm thinking, the environment is network-based, does various TCP/IP calls through stacks... Perhaps the ports/sockets get gooffed up after days and days for reloading, debugging.

Hope this helps a bit...

I occasionally run into this problem too on MacOS. Like @patrice4github the only thing that works for me is rebooting the computer.

@Jonovono
When I entered your solution in my terminal, this is what it showed
No such keg: /usr/local/Cellar/watchman

Was this page helpful?
0 / 5 - 0 ratings