Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native issue: Module does not exist in the Haste module map

I created a native module and created another project to test it locally.

Here are my steps: cd <Testing project> npm install ../<Module project> react-native link <module name> react-native run-android

Then I got following error:

 error: bundling failed: Error: Unable to resolve module `react-native-helloworld` from `G:\Test\App.js`: Module `react-native-helloworld` does not exist in the Haste module map

    This might be related to https://github.com/facebook/react-native/issues/4968
    To resolve try the following:
      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-*`.

enter image description here

I've searched StackOverflow for the issue, but there's no workable solution. The suggested solution 'clear the cache and reset everything' cannot work.

However, the module can work if I publish it to https://www.npmjs.com/ and then install it via npm install <module name>.

The only difference is the installing way.

like image 400
yushulx Avatar asked Nov 07 '22 00:11

yushulx


1 Answers

I got a similar error complaining about how it could not find 'path' from where ever it was looking for. In the end I figured out that the issue was completely unrelated.The following auto import was accidentally added to my code (probably when I was creating a style using 'textTransform')

import { transform } from "@babel/core";

Once I noticed that and removed it, the project was buildable. It might help to check recent changes in your code to see if something similar got added.

like image 152
humblePilgrim Avatar answered Nov 14 '22 21:11

humblePilgrim