问题
When I install NativeBase and React-Native-Router-Flux in my react-native project I get this error:
Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name: react-native-vector-icons
Paths: /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/local-cli/core/__fixtures__/files/package.json collides with /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native-router-flux/node_modules/react-native/local-cli/core/__fixtures__/files/package.json
This error is caused by a @providesModule declaration with the same name across two different files.
Error: @providesModule naming collision:
Duplicate module name: react-native-vector-icons
Paths: /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/local-cli/core/__fixtures__/files/package.json collides with /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native-router-flux/node_modules/react-native/local-cli/core/__fixtures__/files/package.json
This error is caused by a @providesModule declaration with the same name across two different files.
at HasteMap._updateHasteMap (/Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:159:13)
at p.getName.then.name (/Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:134:31)
回答1:
Solution was posted here
yarn add react-native-router-flux@3.38.0
回答2:
You should be able to update
react-native-router-flux using:
npm i react-native-router-flux --save
It may be that trying to start the react-native packager fails again and running may be useful:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start --reset-cache`.
You may see once attempting to run the packager again errors such as:
Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name
You may need to run the npm install for react-native-router-flux again.
回答3:
If you work with yarn, please run this command.
yarn add react-native-router-flux@3.38.0
And if you work with npm, please run this command.
npm install react-native-router-flux@3.38.0 --save
Also you still get the issue, please downgrade react-native version to 0.41.2.
Then, it will work.
回答4:
NativeBase 2.1.4 solves this issue
来源:https://stackoverflow.com/questions/43540811/duplicate-module-name-react-native-vector-icons