ios 重复模块名称:react-native

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50805753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:44:13  来源:igfitidea点击:

Duplicate Module Name: react-native

iosreact-nativecocoapods

提问by Kamil Kamili

I ran Pod Updatein my XCode Project and now my project isn't compiling due to duplicate modules being downloaded. Anyone know any solutions?

Pod Update在我的 XCode 项目中运行,现在由于下载了重复的模块,我的项目没有编译。任何人都知道任何解决方案?

Looking for JS files in
   /Users/.../App/Finalv2 


Metro Bundler ready.

Loading dependency graph...jest-haste-map: @providesModule naming collision:
  Duplicate module name: react-native
  Paths: /Users/.../App/Finalv2/node_modules/react-native/package.json collides with /Users/.../App/Finalv2/ios/Pods/React/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.
Loading dependency graph, done.

UPDATE:I deleted my node_modulesfolder and package.lock.jsonand ran npm installbut the issue is still there

更新:我删除了我的node_modules文件夹并package.lock.json运行,npm install但问题仍然存在

EDIT:

编辑:

Adding my Package.json

添加我的 Package.json

{
  "name": "sample-app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@expo/vector-icons": "^6.2.2",
    "art": "^0.10.1",
    "axios": "^0.17.1",
    "expo": "^24.0.2",
    "firebase": "^4.6.0",
    "lodash": "^4.17.4",
    "moment": "^2.19.3",
    "native-base": "^2.3.3",
    "prop-types": "^15.6.0",
    "react": "^16.3.1",
    "react-native": "^0.55.3",
    "react-native-camera": "^0.10.0",
    "react-native-circular-progress": "git+https://github.com/kk1429/react-native-circular-progress.git",
    "react-native-countdown-circle": "^2.0.0",
    "react-native-country-picker-modal": "^0.5.1",
    "react-native-device-info": "^0.13.0",
    "react-native-easy-grid": "^0.1.16",
    "react-native-elements": "^0.18.5",
    "react-native-fcm": "^11.2.0",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-firebase": "^4.1.0",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-linkedin": "^1.2.1",
    "react-native-material-ui": "^1.19.0",
    "react-native-navigation": "^1.1.471",
    "react-native-progress": "^3.4.0",
    "react-native-pull-refresh": "^1.0.0",
    "react-native-rename": "^2.2.2",
    "react-native-svg": "^5.4.2",
    "react-native-svg-animated-linear-gradient": "^0.1.8",
    "react-native-swiper": "^1.5.13",
    "react-native-tag-input": "git+https://github.com/kk1429/react-native-tag-input.git",
    "react-native-thumbnail-video": "0.0.8",
    "react-native-vector-icons": "^4.4.2",
    "react-native-video": "^2.0.0",
    "react-navigation": "^1.0.0-beta.19",
    "react-redux": "^5.0.6",
    "react-save-refs": "^1.0.2",
    "redux": "^3.7.2",
    "redux-devtools-extension": "^2.13.2",
    "redux-persist": "^5.3.4",
    "redux-thunk": "^2.2.0",
    "whatwg-fetch": "^2.0.3"
  },
  "devDependencies": {
    "babel-jest": "22.1.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.1.4",
    "react-test-renderer": "16.2.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  }
}

UPDATE

更新

Running npm installgives a weird error

运行npm install会出现奇怪的错误

> [email protected] install /Users/.../App/Finalv2/node_modules/fsevents
> node install

[fsevents] Success: "/Users/.../App/Finalv2/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> [email protected] install /Users/kaaddevelopers/Documents/Clipme/App/Finalv2/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.10.1/node-v64-darwin-x64-unknown.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source compile with node-gyp)

回答by Dehli

I just spent some time searching around for a solution and finally found something that worked! I'm not using Firebase, but the discussion here was able to help: https://github.com/invertase/react-native-firebase/issues/414You have to add two lines to your Podfile.

我只是花了一些时间寻找解决方案,终于找到了一些有效的方法!我没有使用 Firebase,但这里的讨论有所帮助:https: //github.com/invertase/react-native-firebase/issues/414您必须在 Podfile 中添加两行。

# Add these to your Podfile
pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

Then run the following to make sure you reinstall your CocoaPods.

然后运行以下命令以确保重新安装 CocoaPods。

cd ios
rm -rf Pods
pod install

回答by MohamadKh75

Try:

尝试:

  1. watchman watch-del-all
  2. rm -fr $TMPDIR/react-*
  3. erase jest-cache folder
  4. rm -rf node_modules
  5. npm install
  6. npm cache clean && npm start -- --reset-cache
  1. watchman watch-del-all
  2. rm -fr $TMPDIR/react-*
  3. erase jest-cache folder
  4. rm -rf node_modules
  5. npm install
  6. npm cache clean && npm start -- --reset-cache

Update

更新

Also try to download the latest node jsand run npm install -g npm

也尝试下载最新的节点js并运行npm install -g npm

回答by Cyrus Zei

remove the "React" folder inside of your "Pod" folder

删除“Pod”文件夹中的“React”文件夹

add this inside of your pod file at the bottom after the last end

将此添加到您的 pod 文件中的最后一个之后的底部 end

post_install do |installer|
  installer.pods_project.targets.each do |target|

# The following is needed to ensure the "archive" step works in XCode.
# It removes React & Yoga from the Pods project, as it is already included in the main project.
# Without this, you'd see errors when you archive like:
# "Multiple commands produce ... libReact.a"
# "Multiple commands produce ... libyoga.a"

    targets_to_ignore = %w(React yoga)

    if targets_to_ignore.include? target.name
      target.remove_from_project
    end

  end
end

remove your Podsfolder and then go pod install

删除您的Pods文件夹,然后去 pod install

回答by TheJoker

Adding to @Dehli's answer, this could happen if:

添加到@Dehli 的回答中,这可能发生在:

  1. You have react-native as 'dependency' for a react-native module

    Solution: Move react-native to 'peerDependency' in package.json

  2. You've moved to peerDependency and have your application's package-lock.json listing react-native as a dependency to your module

    Solution: Delete package-lock.json in your application, clean npm_modules folder and run npm installagain

  1. 您将 react-native 作为 react-native 模块的“依赖项”

    解决方案:将 react-native 移动到 package.json 中的 'peerDependency'

  2. 您已转移到 peerDependency 并让您的应用程序的 package-lock.json 将 react-native 作为您模块的依赖项列出

    解决方案:删除应用中的 package-lock.json,清理 npm_modules 文件夹并npm install再次运行

回答by Heo ??t Hades

In my case, because I linked a library by pod, so it auto install react to pods. So I updated my podfile:

就我而言,因为我通过 pod 链接了一个库,所以它会自动安装对 pod 做出反应。所以我更新了我的 podfile:

target 'MyProject' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  rn_path = '../node_modules/react-native'
  pod 'React', path: rn_path, subspecs: [
   'Core',
   'CxxBridge',
   'DevSupport',
   'RCTActionSheet',
   'RCTAnimation',
   'RCTGeolocation',
   'RCTImage',
   'RCTLinkingIOS',
   'RCTNetwork',
   'RCTSettings',
   'RCTText',
   'RCTVibration',
   'RCTWebSocket',
 ]
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
//Another libraries here
  pod 'RNImageTools', :path => '../node_modules/react-native-image-tools-wm'


  post_install do |installer|
    installer.pods_project.targets.each do |target|

      # The following is needed to ensure the "archive" step works in XCode.
      # It removes React & Yoga from the Pods project, as it is already included in the main project.
      # Without this, you'd see errors when you archive like:
      # "Multiple commands produce ... libReact.a"
      # "Multiple commands produce ... libyoga.a"

      targets_to_ignore = %w(React yoga)

      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

    end
  end

end

Then I remove Podsfolder and run pod install. That alls.

然后我删除Pods文件夹并运行pod install. 就这样。