How do I fix a failure to build due to a "Duplicate module name" collision in a react-native?

352 views Asked by At

RN 0.39.2

This may sound like a duplicate of React-Native Packager Failure: Duplicate module name but there aren't any real fixes in there, just workarounds. There are others but they are for older versions of RN or are similar but different root causes. I have my own workaround (see below) but I'd like to actually solve the problem instead of having to do this workaround five times a day.

The error:

Failed to build DependencyGraph: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/collumj/research/kishar-nine/ios/build/Build/Products/Debug-iphonesimulator/kisharNine.app/package.json 
  collides with 
  /Users/collumj/research/kishar-nine/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

The workaround (for me):

rm -rf android ios
git reset --hard
npm start

There must be a way to actually resolve this. Did this package not link properly? I installed it when I added in NativeBase (http://nativebase.io/docs/v0.5.13/getting-started).

Update: also tried unlinking the react-native-vector-icons library (because apparently you don't need to? unsure, the linking may be redundant in the instructions). Anyway, it didn't work, same error.

2

There are 2 answers

1
jcollum On BEST ANSWER

Edit: OK this may not have actually worked, checking now...

The solution to this was to use react-native unlink to unlink the react-native-vector-icons library. I think the native-base library's instructions are out of date about the need to use link. Maybe? Not really sure but I can say that after unlinking I can still use icons:

<View style={{
    marginTop: 10,
    flexDirection: "row"
}}>
    <H3 style={{
        marginRight: 5
    }}>Icons:</H3>
    <Icon name='ios-home'/>
    <Icon name='ios-menu' style={{
        fontSize: 20,
        color: 'red'
    }}/>
</View>

Renders fine.

0
agenthunt On

Could be if you used the npm command instead of the yarn command. Try deleting node_modules directory. npm cache clean and then yarn install