Skip to content

Unable to resolve module react-native #11257

Closed

Description

@EIrwin

We use GitHub Issues for bugs.

Description

I recently created a new project using react-native init MyProject. The app ran fine initially.

However now, when I run react-native run-ios or try to use xcode to run the app. I get the following error screen.

screen shot 2016-12-01 at 6 44 02 pm

I have followed the suggested instructions and have ran the following

rm -rf node_modules
rm -rf $TMPDIR/react-* --reset-cache
rm -rf node_modules/react-native/packager/packager.sh --reset-cache
npm cache clean
npm i

But I still experience the same problem

I have verified that react-native is in fact installed at the correct location.

  • React Native version: 0.38.0
  • Platform: iOS
  • Operating System: MacOS

Activity

  1. tedjames commented on Jan 8, 2017

    @tedjames

    Refer to this issue for a temporary workaround: #11498

  2. Thibaut-Fatus commented on Feb 15, 2017

    @Thibaut-Fatus

    The workaround does not fix the problem, we keep running into Unable to resolve module

    RN 0.41

    EDIT : all dependencies need to be declared / installed in react-native app directory, not in some parent directory, even if react-packager tells us he looks into others directories.

  3. nhuthuynh commented on Feb 20, 2017

    @nhuthuynh

    i have the same problem and the workaround does not fix mine :(. Any other suggestion ?

  4. achakra21 commented on Apr 9, 2017

    @achakra21

    I am also facing the same issue after installing "npm install --save react-native-calendar-picker"
    capture

  5. ifalldev commented on Apr 10, 2017

    @ifalldev

    +1

  6. wagstaffwm commented on Apr 11, 2017

    @wagstaffwm

    +1 - i've gutted 2 projects now because of this, yikes

  7. achakra21 commented on Apr 11, 2017

    @achakra21

    @wagstaffwm i resolve this by downgrading the React-Native can you please mention exactly which scenario you got this error..In my case my node module was corrupted..

  8. ifalldev commented on Apr 11, 2017

    @ifalldev

    I resolved this using the react-native-git-upgrade package instead of react-native upgrade to upgrade the project. And because of this I had to use yarn instead of npm.

    So, i did something like that:

    npm i -g react-native-git-upgrade
    
    git clone https://github.com/ifalldev/repo
    cd repo
    
    yarn
    yarn add react@16.0.0-alpha.6
    yarn add react-native@0.43.3
    react-native-git-upgrade
    
    rnpm link
    
    react-native run-ios
    
  9. wagstaffwm commented on Apr 11, 2017

    @wagstaffwm

    @ifalldev I am going to try to today I work another job during the day so it maybe tonight or later this week before I can report back thank you for the reply

  10. DamienBell commented on May 13, 2017

    @DamienBell

    I was able to resolve this issue with an earlier version of parse.
    "parse": "~1.8.2"

  11. realpratiknikam commented on May 28, 2017

    @realpratiknikam

    I'm getting same error for "http" module! I tried all techniques mentioned at various places but nothing works. Any luck?

  12. ifalldev commented on May 30, 2017

    @ifalldev

    @prabakarviji, in my case I had to manually add react@16.0.0-alpha.6 and react-native@0.43.3 because the react-native-git-upgrade package crashes without it.

    Can you bring a little more detail of your scenario?

    I noticed this error probably occurs because of the incompatible versions of the packages.

  13. artyomtrityak commented on Jun 26, 2017

    @artyomtrityak
    Contributor

    After upgrading to react native 0.45.1 i have same issue.
    What i did:

    1. npm install --save react-native@0.45.1
    2. react-native upgrade
    3. react-native link
    4. remove node_modules
    5. Clear cache

    Result - Unable to find module React Native

  14. Jahans3 commented on Jul 4, 2017

    @Jahans3

    +1

    Using RN v44.2 and this is happening to me, the workaround isn't working either.

  15. Jahans3 commented on Jul 11, 2017

    @Jahans3

    This issue is now intermittent for me. It's getting ridiculous though. I'll spend a while solving the issue, trying every available fix, only for it the problem to crop up shortly after.

    The only thing that consistently works, even if it is very temporary, is to completely destroy the folder containing the RN project and clone the repo again. This allows me to work on the project until I need to download a new npm module or do an rm -rf node_modules && npm i.

    Should I have to add a new npm module or update a package, I have to update it via the package.json, break the project, commit my changes, then cd .. && rm -rf project_name && git clone https://project-repo && cd project_name && git checkout current_working_branch && yarn install && yarn run-project-name.

    Hope this helps someone in the meantime but a more permanent fix is urgently needed, this issue is seriously hampering my ability to get work done in a timely manner.

  16. elvenvdk commented on Jul 11, 2017

    @elvenvdk

    +1
    Holy shit this sucks...

  17. elvenvdk commented on Jul 11, 2017

    @elvenvdk

    Actually found something. I was getting the same error and just now after my first comment I checked if I had yarn installed and which version. After hitting yarn -v it installed itself and all of the dependancies that were removed during my npm install --save firebase. After the install, in another terminal instance I re-ran npm run start which didn't have any issues then in the main terminal instance I ran react-native run-ios and that totally ran smoothly. When the problem (which this thread is about) was happening I couldn't run react-native run-ios because it didn't even recognize the root folder as a react-native file. Now it does. So give it a try. It doesn't seem like a quick fix, it seems stable now. Saying that we'll see how it goes... keeping a watchful eye.

  18. jestjosh commented on Aug 10, 2017

    @jestjosh

    @elvenvdk So far so good.

  19. mukeshkamboj commented on Sep 28, 2017

    @mukeshkamboj

    I am getting the below error. I have tried out the steps mentioned in the error console. But no luck.

    	"react": "16.0.0-alpha.12",
    	"react-native": "0.48.3",
    

    error

    The development server returned response error code: 500

    URL: http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false

    Body:
    {"from":"/Users/abc/development/react_native/node_modules/react-native-root-siblings/lib/AppRegistryInjection.js","to":"react-native/Libraries/EventEmitter/EventEmitter","message":"Unable to resolve module react-native/Libraries/EventEmitter/EventEmitter from /Users/abc/development/react_native/node_modules/react-native-root-siblings/lib/AppRegistryInjection.js: Module does not exist in the module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman watch-del-all.\n 2. Delete the node_modules folder: rm -rf node_modules && npm install.\n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]}
    processBundleResult
    BundleDownloader.java:170
    access$100
    BundleDownloader.java:39
    onResponse
    BundleDownloader.java:139
    execute
    RealCall.java:135
    run
    NamedRunnable.java:32
    runWorker
    ThreadPoolExecutor.java:1113
    run
    ThreadPoolExecutor.java:588
    run
    Thread.java:818

  20. stale commented on Nov 27, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

  21. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Nov 27, 2017
  22. arshbot commented on Jan 3, 2018

    @arshbot

    Followed @elvenvdk's advice. That error was silenced, but now I'm getting this error instead:

    image

    Along with this error when running react-native run-ios

    ** BUILD FAILED **
    
    
    The following build commands failed:
    
    	CompileC build/Build/Intermediates.noindex/hail-react-native.build/Debug-iphonesimulator/hail-react-nativeTests.build/Objects-normal/x86_64/hail-react-nativeTests.o hail-react-nativeTests/hail-react-nativeTests.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    (1 failure)
    
  23. arshbot commented on Jan 3, 2018

    @arshbot

    I resolved this with this comment after trying every solution under the sun.

    1. delete ios/ or android/
    2. react-native eject <-- this was what did it for me
    3. react-native-git-upgrade
    4. react-native link
    5. react-native run-ios
  24. dwilt commented on Jan 27, 2018

    @dwilt

    Just running react-native-git-upgrade in my project solved it for me. Even though it didn't update anything:

    Dans-MacBook-Pro:the-resistance dwilt$ react-native-git-upgrade
    git-upgrade info Check for updates 
    git-upgrade info Using yarn 1.3.2 
    git-upgrade info Read package.json files 
    git-upgrade info Check declared version 
    git-upgrade info Check matching versions 
    git-upgrade info Check React peer dependency 
    git-upgrade info Check that Git is installed 
    git-upgrade info Get information from NPM registry 
    git-upgrade info Upgrading to React Native 0.52.2, React 16.2.0 
    git-upgrade info Setup temporary working directory 
    git-upgrade info Configure Git environment 
    git-upgrade info Init Git repository 
    git-upgrade info Add all files to commit 
    git-upgrade info Commit current project sources 
    git-upgrade info Create a tag before updating sources 
    git-upgrade info Generate old version template 
    git-upgrade info Add updated files to commit 
    git-upgrade info Commit old version template 
    git-upgrade info Install the new version 
    rm: ./node_modules/react-native/local-cli/core/fixtures/files/package.json: No such file or directory
    git-upgrade info Generate new version template 
    git-upgrade info Add updated files to commit 
    git-upgrade info Commit new version template 
    git-upgrade info Generate the patch between the 2 versions 
    git-upgrade info Save the patch in temp directory 
    git-upgrade info Reset the 2 temporary commits 
    git-upgrade info Apply the patch 
    git-upgrade info Upgrade done 
    Dans-MacBook-Pro:the-resistance dwilt$ 
    
  25. ShawnMercado commented on Feb 17, 2018

    @ShawnMercado

    I just ran into this in a brand new project. Definitely not stale and none of the suggested actions change anything.

  26. astone123 commented on Feb 21, 2018

    @astone123

    Also getting this error when trying to import a new package from node_modules.

    Unable to resolve module "events"

    I've tried all of the suggested fixes and none have worked for me... please help!

  27. gamsim commented on Mar 16, 2018

    @gamsim

    I had this problem too. When I ran "react-native start" it told me a bundler was already running on port 8081. It happened to be from Visual Studio Code. I closed this and ran the command "react-native start" and then the command "react-native run-ios". Seemed to fix the problem.

  28. locked and limited conversation to collaborators on May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions