React-native: React-native bundle command generated old main.jsbundle file

Created on 23 Nov 2015  路  32Comments  路  Source: facebook/react-native

This issue is driving me insane. Every time I run the bundle command it bundles an old version that I previously bundled. I'm not sure where this old code is being cached and loaded from. Running latest version. Anyone?

Locked

Most helpful comment

I vote to reopen this issue.

All 32 comments

Check the time stamp on main.jsbundle after you bundle. Does it change?

I have the same issue.. It's stuck on the old one..

I've been facing this issue as well. Anybody found any solution for this?

I found the problem
Run the command in a terminal: ps ax | grep react-native
Kill all processes and run bundle script again.

@regeda didn't work for me, even rebooting the computer

I found a workaround. I renamed the bundle the main2.jsbundle and changed the reference in appdelegate. This seems to work. For some reason it seems to only cache main.jsbundle

Ran into the same issue. Cleaning in Xcode before doing every build worked for us.

@bellicose100xp - Could you try @jjshammas suggestion and report back to us if it did the trick?

You can also try clearing the packager cache and see if it helps rm -rf $TMPDIR/react-*

@christopherdro @jjshammas suggestion didn't work but @slavik0329 suggestion did. I changed the name of the bundle to main2.jsbundle and changed the reference in appDelegate.m file

so i changed the name back to main.jsbundle and builds are working fine without doing anything else.. I don't really know what fixed it since I've tried all of the suggestions listed in this thread..

@bellicose100xp This might sound silly, but have you tried restarting your computer?

Almost every time I've ran into issues that kept me scratching my head, a simple restart did the trick.

@regeda's trick seemed to work for me!

In my case, I had stupidly added a manually generated main.jsbundle to my existing project via XCode (since it did not have main.jsbundle like newly created projects) which automatically added it to the Copy Bundle Resources step in Build Phases (I had no idea that it would do that)

I removed main.jsbundle from the Copy Bundle Resources step, removed it from my project and cleared the packager's cache (rm -rf $TMPDIR/react-*)

Now everything works right.

It's a pretty complicated build system.

@christopherdro 's solution of restarting my computer allows you to make a change to the JS and bundle once. After more than one time, it keeps reusing the already generated main.js bundle. So if I want to make anymore changes after bundling once, I need to restart my computer again.

Has there been any progress on this?

BTW, this seems to have started happening to me after I upgraded to 0.15.0. It worked on 0.14.2 and below.

rm -rf $TMPDIR/react-* did the trick for me. thanks @satya164

Having the same issue on 0.15.0, resolved with @satya164's suggestion as well.

rm -rf $TMPDIR/react-*

me too, have to do the above

Running with option --resetCache true works for me.

Is seems that there are workarounds were identified, but the underlying issue was not fixes. Unless there is a reason I am missing to reuse the cached main.jsbundle? That seems very odd since the xcode project takes care of generating the bundle and that is hidden from the user so there is no way for developers to know that a cache version is being used. It seems like either this is still a bug or --resetCache true should be added to react-native/packager/react-native-xcode.sh.

The linked issue #4268 was closed in favor of this bug. Should this be reactivated or is there another bug tacking a fix?

I'm having the same issue with latets react-native, i think this one should be re-opened

Running rm -rf $TMPDIR/react-* did the trick which shows it's a react-native issue and should be fixed accordingly. On a previous app I had accidently submitted an old version of my app because of that.

God, I'm glad I ran across this thread. I've been pulling my hair out doing build cleans, touch, remove/readd main.jsbundle, etc. and nothing worked before except literally generating an all-new XCode project.

@satya164's suggestion worked like a charm. Also on 0.15.0.

Been there. --reset-cache really needs to be added to the build script. Can this be reopened to the original point that the build command generates an outdated bundle?

I'm not sure why this ticket is closed, the issue happens to me on Mac OSX on 0.17.

My method of getting around is to make my 'Bundle React Native code and images' Build Phase look like this:

if [ "${CONFIGURATION}" = "Release" ]; then
# https://github.com/facebook/react-native/issues/4289
echo "DELETING CACHED DATA FOR RELEASE"
rm -rf $TMPDIR/react-*
fi

../node_modules/react-native/packager/react-native-xcode.sh

Hacky, but so far it works.

Can not work at all. Every time I change & save a file - I get old results like I changed nothing. Working with ios emulator.

I vote to reopen this issue.

I too am having this issue after upgrading to RN 0.23.1 on Windows/Android. I find I have to uninstall the App on Genymotion and rebuild in order for it take in my changes.

It's weird though, some changes are reflected but some others are not (even though I make changes in the SAME file).

I was also facing this problem on IOS and Windows 10. Below are the commands i use to create signed apk.

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

Mac
watchman watch-del-all && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache

Windows
Permanent delete node_modules
npm cache clean 鈥揻orce
npm install
npm start -- --reset-cache

Open SDK -> Click on rebuild -> Fixed gradle build issue -> click on rebuild again -> generate signed apk.

I have tried removing $TMPDIR, cleaning XCode, yarn cache clean, watchman watch-del-all.
It's still giving me old bundle.

Could the bundle be residing somewhere other than $TMPDIR?

Still having the same bug with the following config:

Environment:
OS: macOS Sierra 10.12.4
Node: 8.1.2
Yarn: 0.24.6
npm: 5.5.1
Watchman: 4.9.0
Xcode: Xcode 8.3.3 Build version 8E3004b
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.52.2 => 0.52.2

I tried to run this:

$: react-native start --reset-cache

But it seems the option has no effect.

PS, if I have errors in my js-files bundling fails.

Was this page helpful?
0 / 5 - 0 ratings