React Native CLI 错误 JSON::ParserError - 无法解析文件中的 JSON:'/.../Flipper/0.232.0/Flipper.podspec.json'

问题描述 投票:0回答:3

我在初始化 React Native 项目时遇到错误。 Macbook M1,我已经尝试通过brew安装并清除缓存。但我不明白错误是什么,为什么 json 文件无法读取或者不是那个错误。

我已经重新安装了 macOS,rm -rf ~/.cocoapods/repos/trunk/ 和其他东西,重新安装 - 没有任何帮助!

✖ Installing CocoaPods dependencies (this may take a few minutes)
error Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

错误

JSON::ParserError - Failed to parse JSON at file: '/Users/mykytakhaliavkin/.cocoapods/repos/trunk/Specs/a/e/a/Flipper/0.232.0/Flipper.podspec.json'.

unexpected token at ''
/Users/mykytakhaliavkin/RN6/vendor/bundle/ruby/2.6.0/gems/cocoapods-core-1.13.0/lib/cocoapods-core/specification/json.rb:66:in `rescue in from_json'
react-native cocoapods react-native-cli flipper
3个回答
0
投票

您需要更换网络。运行后连接VPN

pod install

0
投票

我也遇到同样的问题。更改网络没有帮助。


0
投票

我遇到了同样的问题,这似乎是其他人也遇到的问题 - https://github.com/CocoaPods/CocoaPods/issues/12115

我发现的唯一两个临时解决方案是:

  1. 手动将空的 podspec 文件(例如 https://cdn.cocoapods.org/Specs/a/e/a/Flipper/0.232.0/Flipper.podspec.json)复制到相应位置(例如
     ~/.cocoapods/repos/trunk/Specs/a/e/a/Flipper/0.232.0/Flipper.podspec.json
    )在空的上面。

  1. Podfile
    中指定源的行从
    source 'https://cdn.cocoapods.org/'
    更改为
    source 'https://github.com/CocoaPods/Specs.git'
    (如果缺少,则将其添加到顶部)。这样 pod install 需要更长的时间,但至少它可以工作。
© www.soinside.com 2019 - 2024. All rights reserved.