代码之家  ›  专栏  ›  技术社区  ›  Cory Robinson

用“使用本地模块”来回应本机ios Podfile问题!”

  •  0
  • Cory Robinson  · 技术社区  · 6 年前

    在我的react native项目中(react-native@0.60)在ios/dir中我运行 pod install 得到这个错误:

    [!] Invalid `Podfile` file: no implicit conversion of nil into String.
    
     #  from /Users/coryrobinson/projects/hhs2/ios/Podfile:37
     #  -------------------------------------------
     #  
     >    use_native_modules!
     #  end
     #  -------------------------------------------
    
    

    这是我的播客文件

    platform :ios, '9.0'
    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    
    target 'hhs2' do
      # Pods for hhs2
      pod 'React', :path => '../node_modules/react-native/'
      pod 'React-Core', :path => '../node_modules/react-native/React'
      pod 'React-DevSupport', :path => '../node_modules/react-native/React'
      pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
      pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
      pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
      pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
      pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
      pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
      pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
      pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
      pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
      pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
      pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
      pod 'RNFS', :path => '../node_modules/react-native-fs'
    
      pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
      pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
      pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
      pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
      pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
    
      pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
      pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
      pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
    
      target 'hhs2Tests' do
        inherit! :search_paths
        # Pods for testing
      end
    
      use_native_modules!
    end
    
    target 'hhs2-tvOS' do
      # Pods for hhs2-tvOS
    
      target 'hhs2-tvOSTests' do
        inherit! :search_paths
        # Pods for testing
      end
    
    end
    
    1 回复  |  直到 6 年前
        1
  •  34
  •   Blue Bot    6 年前

    以下是正确答案:

    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    

    2-确保 package.json node_module

    cli-platform-ios/native_modules

    3-如果你跑了之后没有找到 yarn install -意味着您的计算机中有旧的缓存节点_模块,您需要在重新安装包之前清理它。

    4-清理缓存 yarn cache clean

    5-确保你有这个文件 react-native.config.js 而且它的配置是有效的-而且它没有不存在的NPM包-这一步是最后一步,也是错误的主要原因

    反应-native.config.js

    module.exports = {
      project: {
        ios: {},
        android: {},
      },
      assets: ['./assets/fonts/'],
      dependencies: {}, // make sure this dependencies are all valid installed packages or empty if you don't need it
    };
    

    纱线安装 pod install --repo-update

    编码快乐!

        2
  •  6
  •   Vitor Lopes    6 年前

    补充

    "@react-native-community/cli-platform-ios": "3.0.0"
    

    到包.json.

    运行npm install,然后运行pod install以使其再次工作。

        3
  •  5
  •   MoOx    6 年前

    如果你正在使用

    pod install --project-directory=ios
    

    use_native_modules!

    use_native_modules!(".")

    https://github.com/react-native-community/cli/issues/657

        4
  •  3
  •   ToniG    6 年前

    我刚刚删除了整个node_modules和RN cache文件夹,并重新安装了一次,这修复了目前为止“使用本机_modules”的问题……但在那之后,我不得不与其他lib发生了很多麻烦,而这些lib还没有准备好RN0.60;)

        5
  •  3
  •   Naveen Raju    6 年前

    对我来说,我删除了 node_modules 然后用 npm install . 在那之后,我导航到 /ios pod install 成功了。

        6
  •  2
  •   jsina    6 年前

    这是因为你的设备上过时的纱线版本, 如果您在macOS上,您可以通过以下链接升级/安装yarn: here it is

    注意 删除 node-module yarn.lock 网间网操作系统 pod install .

        7
  •  2
  •   B. Mohammad    6 年前

    @react-native-community/cli-platform-ios 在你的 包.json ,

    npm install @react-native-community/cli-platform-ios

    然后

    cd ios && pod install

        8
  •  1
  •   Arnav Nagpal    5 年前

    不要用纱线安装。这对我很有效。。。

    • 转到主文件夹
    • 删除节点文件夹
    • sudo npm install 或者只是 npm install
    • cd ios
    • pod install
        9
  •  0
  •   Cory Robinson    6 年前

    pod install 作品。

        10
  •  0
  •   Jonas Sourlier    6 年前

    我试过之后就犯了这个错误 react-native run-ios 世博应用程序。我得到的错误表明豆荚出了问题,所以我跑了 cd ios && pod install ,这就是为什么我得到了一个与操作类似的错误。

    expo start 而不是

        11
  •  0
  •   Matthew Gruman    6 年前

    这是今天突然发生的,问题是我的目录结构中有一个空间。前任:

    /路径/to/Directory\Name/RNProject抛出!本机模块错误 /路径/to/DirectoryName/RNProject正常工作

    Pods在找“目录”

        12
  •  0
  •   Doug Watkins    6 年前

    不管是什么原因,我最终创造了一个 AndroidManifest.xml 文件在我的安卓原生设置。

    我查看了完整的错误输出,错误的第一行引用了行号和列号。在我的xml文件中,我破坏了xml格式。

    look .

        13
  •  0
  •   Mayur Shingare    6 年前

    可能跟权利问题有关

    为我工作

        14
  •  -1
  •   Vikas    6 年前

    原因之一可能是Ruby的过时版本。使用以下命令升级它。

    rvm install 2.6.1
    rvm use 2.6.1 --default
    

    或者您可以阅读下面的文章,其中详细解释了如何升级ruby和相关gems。

    https://help.learn.co/en/articles/2789231-how-to-upgrade-from-ruby-2-3-to-2-6

        15
  •  -1
  •   Max MacLeod Lapinou    6 年前

    问题是:

    use_native_modules!
    

    CocaoPods website 1.5.2 .

    运行:

    pod --version
    

    检查哪个版本。如果需要,请卸载,然后在终端中重新安装,方法是运行:

    sudo gem install cocoapods
    

    1.8.4 . 成功安装后,重新尝试 pod install 希望一切都好。

        16
  •  -1
  •   Tyler Agnew    6 年前

    • 更改Ruby版本
    • 改变可可豆的版本

    我无法解决这个问题。这似乎是一些npm依赖,但我的团队中的其他人没有看到。

        17
  •  -2
  •   sean helvey    6 年前

    摆脱这条线 use_native_modules!

    react-native init APP_NAME --version react-native@0.59.10

        18
  •  -3
  •   Innocent TRA BI    6 年前

    转到此存储库: 在Podfile中,删除use_native_modules! 再次执行pod安装