question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Newly create local module does not exist in Haste module map

See original GitHub issue

šŸ› Bug Report

Iā€™m trying to import a module I created in my App.js file

import RNModule from 'react-native-module';

The module is not found by metro when trying to load the project. screen shot 2019-02-07 at 5 40 26 pm

Yes I have tried:

1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.

It however works if you import the module using NativeModulesā€¦

import { NativeModules } from 'react-native';
const { RNModule } = NativeModules;

To Reproduce

  1. Create project using react-native init
  2. Create a library using react-native-create-library
  3. npm install your library from your project
  4. react-native link <your library>
  5. import the library in the App.js (or anywhere else) of the project
  6. Try run react-native run-android or react-native run-ios

Expected Behavior

The project should load without issues.

Code Example

https://github.com/814k31/TestReactNativeNativeModule

Environment

React Native Environment Info: System: OS: macOS 10.14.2 CPU: (8) x64 IntelĀ® Coreā„¢ i7-6700K CPU @ 4.00GHz Memory: 486.52 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.13.0 - /usr/local/bin/node npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 22, 23, 26, 27, 28 Build Tools: 23.0.1, 25.0.0, 26.0.2, 27.0.3, 28.0.0, 28.0.2, 28.0.3 System Images: android-28 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.2 AI-181.5540.7.32.5014246 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.6.3 => 16.6.3 react-native: ^0.58.3 => 0.58.3 npmGlobalPackages: create-react-native-app: 2.0.2 react-native-ci-tools: 1.1.0 react-native-cli: 2.0.1 react-native-create-library: 3.1.2 react-native-git-upgrade: 0.2.7

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
bartolkaruzacommented, Feb 12, 2019

@814k31 Several options, but the ones I like to use is to checkout the library inside the node_modules or when Iā€™m working on a library and an app project in parallel I use https://github.com/wix/wml

Neither solution is perfect but it gets the job done. Hope this helps you along.

3reactions
bartolkaruzacommented, Feb 8, 2019

@814k31 Thank you for the solid repro repository! Iā€™ve checked out the project and I donā€™t have any issues importing the library. Are you sure you are not symlinking the library into node_modules? Because that doesnā€™t work with the metro bundler https://github.com/facebook/metro/issues/1.

These are the commands that lead to the below screenshot:

  598  git clone https://github.com/814k31/TestReactNativeNativeModule
  599  cd TestReactNativeNativeModule/
  600  ls
  601  cd RNApp/
  602  ls
  603  yarn
  604  cat package-lock.json 
  605  ls -lah node_modules/react-native-module
  606  ls -lah node_modules | grep react-native-module
  607  react-native run-ios
screenshot 2019-02-08 at 17 08 49
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Module does not exist in the Haste module map" when ...
I have created one and wanted to test it locally, but I have a dependency problem. I have generated a module with react-native-create-libraryĀ ......
Read more >
react native unable to resolve module - You.com | The AI ...
Strict. Open links in a new tab ... You can use most of the node core modules this method. ... Module stream does...
Read more >
React Native Issue: Module Does Not Exist In The Haste ...
i created a library using reactnativecreatelibrary named myLib and. Module react does not exist in the Haste module map. for library with onlyĀ ......
Read more >
[Solved]-Unable to resolve module...does not exist in the haste ...
[Solved]-Unable to resolve module...does not exist in the haste module map-React Native ; score:1. Accepted answer. yarn add react-native-tweet-view react-nativeĀ ...
Read more >
react-native-sound/Help - Gitter
Module react-native-sound does not exist in the Haste module map. This might be related to facebook/react-native#4968. To resolve try the following:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found