我试图在iOS模式下运行react本机项目。
$ react-native run-ios
但我正在运行错误
Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name: react-animated
Paths: /Users/mobile/node_modules/react-native-image-carousel/node_modules/react-native/Libraries/Animated/release/package.json collides with /Users/mobile/node_modules/react-native/Libraries/Animated/release/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-animated
Paths: /Users/mobile/node_modules/react-native-image-carousel/node_modules/react-native/Libraries/Animated/release/package.json collides with /Users/mobile/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by a @providesModule declaration with the same name across two different files.
at HasteMap._updateHasteMap (/Users/mobile/node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:158:13)
at /Users/mobile/node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:133:31
我不明白这个问题,确实需要一些帮助才能解决问题。
这就是我设置系统的方式(macOS Sierra):
$ brew install node
$ brew install watchman
$ sudo npm install -g react-native-cli
$ npm install invariant --save-dev
$ npm install
一切都应妥善安装:
版本
$ node -v
v4.0.0
$ react-native -v
react-native-cli: 2.0.1
react-native: 0.40.0
$ watchman -v
4.7.0
的package.json
{
"dependencies": {
"react": "~15.4.0-rc.4",
"react-native": "0.40.0",
"react-native-image-carousel": "^0.3.2",
"react-native-image-picker": "^0.25.7",
"react-native-local-mongodb": "^1.8.2"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"invariant": "^2.2.2",
"jest": "18.1.0",
"react-test-renderer": "~15.4.0-rc.4"
},
"jest": {
"preset": "react-native"
}
}
npm list
$ npm list --depth=0
├── babel-jest@18.0.0
├── babel-preset-react-native@1.9.1
├── invariant@2.2.2
├── jest@18.1.0
├── react@15.4.2
├── react-native@0.40.0
├── react-native-image-carousel@0.3.2
├── react-native-image-picker@0.25.7
├── react-native-local-mongodb@1.8.2
└── react-test-renderer@15.4.2
答案 0 :(得分:1)
清除缓存并再次启动项目。
按照以下步骤清除React Native包中的缓存。
watchman watch-del-all
rm -rf $TMPDIR/react-*
rm -rf node_modules/
npm cache clean
npm install
npm start -- --reset-cache