Duplicate Module Name: react-native

前端 未结 5 1357
梦如初夏
梦如初夏 2021-02-01 14:38

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

Looki         


        
相关标签:
5条回答
  • 2021-02-01 14:41

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

    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 install again

    0 讨论(0)
  • 2021-02-01 14:42

    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

    Update

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

    0 讨论(0)
  • 2021-02-01 14:47

    In my case, because I linked a library by pod, so it auto install react to pods. So I updated my 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 Pods folder and run pod install. That alls.

    0 讨论(0)
  • 2021-02-01 14:50

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

    add this inside of your pod file at the bottom after the last 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 Pods folder and then go pod install

    0 讨论(0)
  • 2021-02-01 15:04

    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/414 You have to add two lines to your 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.

    cd ios
    rm -rf Pods
    pod install
    
    0 讨论(0)
提交回复
热议问题