react-native: "Something went wrong while linking. Error: Cannot read property 'match' of undefined"

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

$ react-native info:

Environment:
  OS: macOS Sierra 10.12.6
  Node: 8.9.1
  Yarn: 1.3.2
  npm: 5.5.1
  Watchman: 4.9.0
  Xcode: Xcode 9.1 Build version 9B55
  Android Studio: Not Found

Packages: (wanted => installed)
  react: 16.0.0 => 16.0.0
  react-native: 0.50.3 => 0.50.3

Target Platform: iOS 11.1

Steps to Reproduce

  1. yarn add react-native-blur@3.2.2
  2. react-native link react-native-blur

Expected Behavior

Package linked without error

Actual Behavior

$ react-native link react-native-blur

rnpm-install info Linking react-native-blur android dependency 
rnpm-install info Android module react-native-blur has been successfully linked 
rnpm-install info Linking react-native-blur ios dependency 
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'match' of undefined 
Please file an issue here: https://github.com/facebook/react-native/issues 

Cannot read property 'match' of undefined

Note that I haven’t seen a similar error, before RN 0.50 or react-native-blur <= 3.2.0

Issue also reported at https://github.com/react-native-community/react-native-blur/issues/246

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (1 by maintainers)

Most upvoted comments

If your iOS project is using CocoaPods (contains Podfile) and linked library has podspec file, then react-native link will link library using Podfile. To support non-trivial Podfiles add # Add new pods below this line comment to places where you expect pods to be added.

@LiuShuoyu in my project there is Pod file with following content:

target 'MyApp'
pod 'Fabric'
pod 'Crashlytics'

and after these lines I need add # Add new pods below this line?

same bug with “react-native”: “^0.50.3” and react-native link ANYTHING => same bug

rnpm-install info Linking react-native-code-push android dependency 
rnpm-install info Android module react-native-code-push has been successfully linked 
rnpm-install info Linking react-native-code-push ios dependency 
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'match' of undefined 

I did the following and it worked:

step1: remove node_modules step2: close xcode step3: cd ios and run pod install (i have use firebase) step4: react-native link ANYTHING => and OK

I hope it will help you

@LiuShuoyu You’re fucking brilliant!

At least in our case, this was related to a “problem” with Podfile. If you’re using cocoapods, react-native link now (#15460) looks for the line target '<project-name>' do, in the Podfile, to figure out where to add cocoapods dependencies, but we had added additional targets to this list, so it no longer matched.

Just chiming in to say that as of Nov 2018 @LiuShuoyu 's workaround still does the job. I came here via google search. I can’t believe the addition of that comment fixes it.

I updated the react-native version to 0.56.0 and got Cannot read property 'match' of undefined for all node_modules.

In my case, I had changed name of ‘app’ through XCode but in Podfile it was still target 'app' do. Changing it to target 'codedamn' do worked for me (codedamn is the name I set through XCode)

You guys can try running react-native upgrade. After running react-native upgrade, the issue is auto-resolved for me.