title: Error: jest-haste-map: Haste module naming collision:
body: <p>I have created a custom <code>npm module</code> (will use <strong>xxx</strong> instead of its name) and link it manually using <code>npm install</code>.</p>
  
  <p>I tried very hard and searched :</p>
  
  <ul>
  <li><a href="https://github.com/facebook/react-native/issues/4968" rel="noreferrer">[Workarounds] Packager unable to resolve module from /Users/node_modules/ </a></li>
  <li><a href="https://stackoverflow.com/questions/52905842/error-jest-haste-map-providesmodule-naming-collision-when-using-a-local-depen">Error: jest-haste-map: @providesModule naming collision when using a local dependency</a></li>
  </ul>
  
  <p>before raising a question. I would be thankful if someone tell me what wrong with my code or my approach or any error in my code.</p>
  
  <p>When I run <code>react-native run-android</code> following error is raised by <code>metro bundler</code></p>
  
  <pre><code>Error: jest-haste-map: Haste module naming collision:
    Duplicate module name: react-native
    Paths: E:\cdg-native\CDG\node_modules\react-native-XXX\node_modules\react-native\package.json collides with E:\cdg-native\CDG\node_modules\react-native\package.json
  
  This error is caused by `hasteImpl` returning the same name for different files.
  </code></pre>
  
  <p>My custom module <code>package.json</code> is</p>
  
  <pre><code>{
    "name": "react-native-xxx",
    "version": "1.0.0",
    "description": "Library to render xxx",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
    },
    "keywords": [
      "react native xxx"
    ],
    "author": "Firdous Nath",
    "license": "ISC",
    "peerDependencies": {
      "react": "*",
      "react-native": "*"
    },
    "devDependencies": {
      "react": "^16.6.1",
      "react-native": "^0.57.5",
      "babel-cli": "^6.26.0",
      "babel-plugin-transform-class-properties": "^6.24.1",
      "babel-plugin-transform-object-rest-spread": "^6.26.0",
      "babel-plugin-transform-runtime": "^6.23.0",
      "babel-preset-env": "^1.6.1",
      "babel-preset-react": "^6.24.1"
    }
  }
  </code></pre>
  
  <p><code>index.js</code> of the custom module is very simple as below</p>
  
  <pre><code>import React from "react";
  import { Text } from "react-native";
  
  export default class XXXView extends React.Component {
  
      render() {
          return (
              &lt;Text&gt; From custom module &lt;/Text&gt;
          );
      }
  }
  </code></pre>
  
  <p>file where I am using custom module is</p>
  
  <pre><code>import React from "react";
  import {StyleSheet, View} from "react-native";
  import XXXView from "react-native-xxx"
  //import {XXXView} from "react-native-xxx" -&gt; I tried this as well
  
  export default class App extends React.Component {
      render() {
          return (
              &lt;View style={styles.container}&gt;
                  &lt;XXXView/&gt;
              &lt;/View&gt;
          )
      }
  }
  
  const styles = StyleSheet.create({
      container: {
          flex: 1,
          justifyContent: "center",
          alignItems: "center",
          backgroundColor: "#f5fcff"
      }
  });
  </code></pre>
  
  <p>I tried <code>npm install /absolute/path/to/xxx</code> and it linked module correctly. By correctly I mean I can see <code>react-native-xxx</code> package in <code>nodemodule</code> directory.
  I did all possible ways but nothing worked.</p>
  
  <p>I also tried but got no success</p>
  
  <ul>
  <li>yarn add /absolute/path/to/react-native-xxx</li>
  <li>react-native link react-native-xxx</li>
  <li>react-native run-android</li>
  </ul>