在`../ node_modules / react-native`中找不到'React`的podspec

时间:2018-01-03 10:36:27

标签: react-native path

React

中找不到../node_modules/react-native的podspec

我在成功安装npm后执行pod安装时遇到上述错误

NPM版本:5.6.0 以下是pod文件

# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
react_native_path = '../node_modules/react-native'
pod 'Yoga', :path => "#{react_native_path}/ReactCommon/yoga"
pod 'React', :path => react_native_path, :subspecs => [
'Core',
'RCTText',
'RCTImage',
'DevSupport',
'BatchedBridge',
'RCTLinkingIOS',
'RCTAnimation',
'RCTActionSheet',
'RCTWebSocket', # needed for debugging
# Add any other subspecs you want to use in your project
]

3 个答案:

答案 0 :(得分:2)

检查文件../node_modules/react-native/React.podspec是否确实存在于Podfile。如果没有,请检查package.json是否真的包含react-native作为依赖项。

对于标准RN项目目录结构,Podfile应放在<projectRoot>/ios/Podfile中,如下所示:

platform :ios, '9.0'

target 'CGUI' do
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'RCTAnimation',
    'RCTBlob',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTImage',
    'RCTLinkingIOS',
    'DevSupport',
  ]
  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'

  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
  pod 'RNFS', :path => '../node_modules/react-native-fs'
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
end

这是针对RN 0.51.0

答案 1 :(得分:0)

  1. 成功安装npm后,
  2. 在项目根目录中删除文件podfile.lock,
  3. 然后在您的项目根目录中安装pod。

这对我有用。

答案 2 :(得分:0)

转到您的项目目录 在终端的IOS写命令打开Xcode

open ios/[projectname].xcworkspace

并从左侧导航栏中打开 Pods 文件夹并打开 Profile 文件 之后删除该行,

pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

并重建项目。