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

Hot reloading error. (Unknown module "react-native") #6731

Closed
amberstar opened this issue Mar 30, 2016 · 31 comments
Closed

Hot reloading error. (Unknown module "react-native") #6731

amberstar opened this issue Mar 30, 2016 · 31 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@amberstar
Copy link

Hot reloading is not working. #6722 was closed as a dup of #6640. #6640 was Unknown module "React", the error I am getting is "Unknown module "react-native"." I tried to debug, but this is day 1 for me with react, node etc.

If it truly is fixed, please explain how to used the fixed version. I am working with a first time fresh install of everything this morning to try react.

I saw this comment:

Should work now that we have released babel-preset-react-native@1.5.5. You'll have to upgrade from 1.5.4 to 1.5.5

As far as I can tell I am up to date using 1.5.5.

Thanks.

@adrienbrault
Copy link
Contributor

Having the same issue. Is there a way to disable hot reloading ?

@magrinj
Copy link
Contributor

magrinj commented Mar 30, 2016

@adrienbrault If you are on iOS device do ⌘ + D and click on Disable Hot Reloading

I'm not sure but for android I think it's ⌘ + M, if you are not on a mac try Control instead of

@RealOrangeOne
Copy link

@adrienbrault Hot reloading should be an opt-in option. I too am having this problem with Hot Reloading, although on Android. However someone else I know on another project is having no problems at all, I fear it's something in the project itself that is causing the problems

@hvsy
Copy link

hvsy commented Mar 30, 2016

+1

@sylvainbaronnet
Copy link

Same issue

@sylvainbaronnet
Copy link

@magrinj I don't have access to ⌘ + D menu since the app crash, is there another way to disable hot reload ?

@magrinj
Copy link
Contributor

magrinj commented Mar 30, 2016

@sylvainbaronnet You can dismiss the error view with the button at the bottom left, after that try again with ⌘ + D, did you do that on an iOS simulator ?

@sylvainbaronnet
Copy link

Thanks !! It works again

@satya164 satya164 reopened this Mar 30, 2016
@satya164
Copy link
Contributor

cc @martinbigio

@jerolimov
Copy link
Contributor

Same error here. After many many try and errors I found that you should always use npm start -- --reset-cache when trying to "find" this issue.

Could reproduce this with a clean react-native init project without any additional dependency.

I found a local project that still works and created two npm-shrinkwrap files which shows that the problem doesn't happen with react 0.14.7 and happen with 0.14.8 (both times react-native 0.22.2).

You find both npm-shrinkwrap files and the npm install output after adding the "old" version and re-run it here: https://gist.github.com/jerolimov/85051d319b69ea6fe8dd24fa0f79f5f4

@martinbigio
Copy link
Contributor

Hmm, mind trying with babel-preset-react-native@1.5.4. Looks like for some people we have problems resolved React and for other react-native.

@cpojer, @skevy has anything changed on node-haste that could explain this? This is where react-transform is configures to import React/react-native:

imports: ['React'],
.

@cpojer
Copy link
Contributor

cpojer commented Mar 31, 2016

I haven't touched anything in node-haste for a while, might wanna ask @davidaurelio :)

@martinbigio
Copy link
Contributor

Started debugging a bit the repro case of #6640 and confirmed react is on the Haste map of the resolver when the packager starts. Maybe the issue is that the dependency is added on transform time by the HMR plugin? That doesn't explain though why this stopped working.

@martinbigio
Copy link
Contributor

Taking a step back I realized this problem is different to the one on #6640. This one happens on runtime whereas the other one on resolution time. The problem we're having now is that the require (react-native) is not getting transformed to the absolute path (react-native/Libraries/react-native/react-native.js). Modifying https://github.com/facebook/react-native/blob/master/babel-preset/configs/hmr.js#L28 with such change fixes the problem.

I need to test this also works internally. If everything is fine I'll update the preset tomorrow with this fix. Sorry for the issue, please remember you can always disable hot reloading. Happy coding!

cc @satya164 :)

@tianwalker2012
Copy link

@martinbigio I followed you steps, it doesn't work :(

@martinbigio
Copy link
Contributor

@tianwalker2012 that's really weird, it does work for me. The file you need to modify is located on node_modules/react-native/node_modules/babel-preset-react-native/configs. Was that one the one you changed? What error are you getting now?

@pasqualino0815
Copy link

@martinbigio I'm having the same issue. I tried both versions:

  • imports: ['react-native']
  • imports: ['react']

The red box displays both times: Requiring unknown module "react-native". If you are sure the module is there, try restarting the packager or running "npm install".

@martinbigio
Copy link
Contributor

I just released a new version of the preset which fixes the issue locally on a brand new project for me. Could you update the preset to 1.5.6? Or create a new project to verify it works?

@amberstar
Copy link
Author

@martinbigio Yes that fixed it for me. Thanks.

@martinbigio
Copy link
Contributor

Would be awesome if a couple more of people confirm this is working for them so that I can commit the code to the repo :)

@gaearon
Copy link
Collaborator

gaearon commented Mar 31, 2016

react-native/Libraries/react-native/react-native.js

😂

@pasqualino0815
Copy link

The updated present is doing something different. I'm receiving now a tiny redbox in the upper left corner:
tinyredbox
;)

@pasqualino0815
Copy link

The problem lies definitely in my app code.
Enabling hot reloading rendering only a simple view as follows works just fine.

     <View>
        <Text>
          Hello World
        </Text>
      </View>

I will try to find out how exactly I can reproduce this.

@pohy
Copy link

pohy commented Mar 31, 2016

The issue persists for me, am using babel-preset-react-native@1.5.6.
player_2016-03-31_15-55-13

@maikokuppe
Copy link

@martinbigio: Works for me after updating babel-preset-react-native with

npm install babel-preset-react-native@1.5.6

Thanks!

@martinbigio
Copy link
Contributor

@pohy as per your screenshot you're not using 1.5.6 because react-native was changed for the full path.

@martinbigio
Copy link
Contributor

@gaearon this is only a temporary hack to fix the issue and unblock people. The underlying problem is not only affecting HMR but also assets, check #6638. We'll ask @davidaurelio to take a look next week when he comes back.

@pohy
Copy link

pohy commented Mar 31, 2016

Interesting, npm ls babel-preset-react-native shows, that I have 1.5.6, and even after fully rebuilding the app, it still does fail with Requiring unknown module "react-native"...

@martinbigio
Copy link
Contributor

make sure to reset the cache npm start -- --reset-cache

@maikokuppe
Copy link

@pohy: You could try to stop the gradle daemon (android/gradlew --stop works for me) and rebuild with react-native run-android.
Just an idea

@pohy
Copy link

pohy commented Mar 31, 2016

@martinbigio Yes, resetting cache helped, thanks for the help and sorry for the hassle!

@ghost ghost closed this as completed in 4133de0 Apr 1, 2016
zebulgar pushed a commit to nightingale/react-native that referenced this issue Jun 18, 2016
Summary:Fixes facebook#6731
Closes facebook#6748

Differential Revision: D3126410

Pulled By: martinbigio

fb-gh-sync-id: fc462ec82e72914d13341a4543212c017bd3838c
fbshipit-source-id: fc462ec82e72914d13341a4543212c017bd3838c
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests