Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeJS doesn't rebuild with new insert #18

Closed
luandro opened this issue Feb 22, 2018 · 16 comments
Closed

NodeJS doesn't rebuild with new insert #18

luandro opened this issue Feb 22, 2018 · 16 comments

Comments

@luandro
Copy link

luandro commented Feb 22, 2018

I'm running a simple express server like the example, and it works. But after changing the nodejs server and rebuilding with cd server && npm i && cd .. && react-native-node insert ./server the changes don't take effect any more.

I've tried deleting node_modules on both the nodejs and the react-native apps, tried deleting the rnbundle that gets saved to the raw folder. Nothing changes the express app once it's been built for the first time.

@staltz
Copy link
Owner

staltz commented Feb 22, 2018

You might need to recompile the android app

@staltz
Copy link
Owner

staltz commented Feb 22, 2018

Gradle

@luandro
Copy link
Author

luandro commented Feb 22, 2018

Is there a react-native command for that? How does that work?

@staltz
Copy link
Owner

staltz commented Feb 22, 2018

react-native run-android

@luandro
Copy link
Author

luandro commented Feb 22, 2018

I run it every time right after running react-native-node insert, still Nodejs app doesn't get updated.

@staltz
Copy link
Owner

staltz commented Feb 22, 2018

./gradlew clean then run-android?

@luandro
Copy link
Author

luandro commented Feb 23, 2018

Took me a while to find out I had to brew install gradle in order to use ./gradlew clean in the android directory.

Finally did, ran it successfully, but still get the first response written in the express server. Still seems the NodeJS apps aren't being rebuilt, despite running the whole thing every time:

"scripts": {
    "dev": "npm run clean && npm run build && npm run android",
    "build": "cd server && npm i && cd .. && react-native-node insert ./server",
    "clean": "cd android && ./gradlew clean && cd ..",
    "android": "react-native run-android"
},

@staltz
Copy link
Owner

staltz commented Feb 23, 2018

Try one more thing: delete android/app/src/main/res/raw/rnnodebundle before all that.

@luandro
Copy link
Author

luandro commented Feb 23, 2018

Added rm android/app/src/main/res/raw/rnnodebundle to the clean script, but still nothing. No idea where the old code is coming from. It should only exist in rnnodebundle, and if that's deleted and recreated with new code, how does it still persist?

Emulating on a MotoG3-TE - 6.0.

@staltz
Copy link
Owner

staltz commented Feb 23, 2018

Oh emulators? I don't think this library works there, because node.js is compiled for ARM architectures, and emulators usually are not ARM.

@luandro
Copy link
Author

luandro commented Feb 23, 2018

Oh sorry, bad use of the word. I'm running the app on the actual phone (I was emulating using Geny Motion, but I read in #5 that emulators don't work).

Is there any thing else we can try?

@staltz
Copy link
Owner

staltz commented Feb 23, 2018

Well, there is nothing else to try if you: (1) remove and rebuild rnnodebundle, (2) rebuild with gradle from scratch, (3) uninstall and reinstall the mobile app. Are you sure you have done those 3? There is no way the previous rnnodebundle can creep in after that

@luandro
Copy link
Author

luandro commented Feb 24, 2018

Got it fixed by using method (3), uninstalling the app on the device. Seems like the device caches the NodeJS application for some reason. Manually going to Settings > Applications > MyApp on the phone and uninstalling it; when rebuilding with react-native the NodeJS application gets rebuilt.

Is there no programmatic way to to this?

Thanks for the help.

@luandro
Copy link
Author

luandro commented Feb 24, 2018

I added adb uninstall com.app_package to my npm scripts, and that solved the problem. I guess this is usual for working with Node in react-native, to have to rebuild at every Node change, right?

I'll close this for now, thanks a lot for the help. Cheers!

@luandro luandro closed this as completed Feb 24, 2018
@staltz
Copy link
Owner

staltz commented Feb 24, 2018

Yeah, we have to rebuild after changes. Recompiling is a normal thing to do when developing mobile apps with Java and Gradle. React Native is what brings something completely new: runtime reloading. It would be a lot more work for me to build runtime reloading of the background process, so we do it the normal way: rebuilding

@staltz
Copy link
Owner

staltz commented Feb 24, 2018

I think the uninstall was important because react-native-node unzips the rnnodebundle in an application directory, and only once (this is to avoid unzipping every time). So I think another way of solving the problem would be rebuild (after a gradle clean), clear the app's cache and data, then run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants