Cli: react-native link @react-native-community/async-storage fails

Created on 27 Mar 2019  ·  42Comments  ·  Source: react-native-community/cli

Environment

info 
  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
      Memory: 352.69 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.12.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5199772
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.6.3 => 16.8.5 
      react-native: ^0.59.2 => 0.59.2 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Description

The link in this new lib fails. The commands states to to log a bug:

$ react-native link @react-native-community/async-storage
info Linking "@react-native-community/async-storage" iOS dependency
error Something went wrong while linking. Error: Cannot read property 'match' of undefined 
Please file an issue here: https://github.com/react-native-community/react-native-cli/issues
error Cannot read property 'match' of undefined

Reproducible Demo

react-native link @react-native-community/async-storage

bug on hold

All 42 comments

Can you reinstall react-native (e.g. remove from lockfile and install again) and see if that helps?

Same thing after a complete clean.

I couldn't reproduce on a clean project. Can you set up a repo with reproduction so we can investigate?

I'll have to admit, "error Something went wrong while linking." is not the greatest error message. It seems like the stack trace is eaten. Perhaps we could start by displaying the full stack trace of the fatal error message and see what object "matched" is called on.

Let me see if I can re-create it outside an my private project.

FYI @Krizzu

Getting the same not sure what it is, I also got it for NetInfo package and managed to get around it by basically re-doing all the pods and deleting node modules and doing a cache clean etc etc... but this time around (with async-storage) none of that seems to be doing it 🤔

React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 84.49 MB / 16.00 GB
      Shell: 5.7.1 - /usr/local/bin/zsh
    Binaries:
      Node: 11.9.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.5.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Xcode: 10.2/10E125 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: ^0.59.2 => 0.59.2
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

I'll try to reproduce it and fix this. It's definitely a bug somewhere in the linking logic that might be happening due to specific structure of your project.

This appears to be longer reproducible after an upgrade to 0.59.3.
I was replaced by another error after an upgrade from 0.59.2 to 0.59.3.

error Failed to get dependency config

I'm not sure if this error stops the link execution and hides the previous error.
I'm attaching the package.json of my project. I've copied the file to brand new project, created with 0.59.3 and this error no doesn't occur there.

With the CLI, are all the errors reported or the does an error fail fast?
(Is there a chance this upgrade error hides the previous one or should it be logged separately?)

Thanks.
package.json.zip

I'll check this out tonight thanks for the update @patrice4github

Can't reproduce on master with any of the packages and fresh react-native init. Please provide a reproduction (ideally package your entire project w/o node_modules and send it to my at [email protected]).

Too bad we can't reproduce it.

About this:

error Cannot read property 'match' of undefined

I think we should focus on displaying the stack trace of such error. The code crashes, knowing where would give us the cause of the error right away, pretty much. Just a suggestion.

Right, give me a second, I'll publish a patch with a fix for that!

@patrice4github please try to re-install react-native to get the cli v1.6.0, you'll be able to run with --verbose which will show the stack trace :)

Linking AppCenter doesn't work too. Will check

We ran into this when upgrading react-native versions with a project name containing a dash (it worked fine before the upgrade).
For some reason, the project name was passed to the react-native CLI as project-name.xcodeproj, but the Podfile had both project and target hard-coded toprojectname. Replacing all instances of the dashed name fixed the issue for us.

run -------- react-native link react-native-webview

error Something went wrong while linking. Error: Expected "/* Begin ", "/* End ", "\"", or [A-Za-z0-9_.] but "<" found.
Please file an issue here: https://github.com/react-native-community/react-native-cli/issues

@codeprolin can you open your project with Xcode and then, run link again? Let me know if that helps.

@thymikee

@zbluephoenix thanks! @grabbou the error comes from findLineToAddPod function, can you investigate?

@thymikee thank you for your reply。 I found a solution.
Add a comment to the Podfile file like this

# Add new pods below this line

屏幕快照 2019-04-12 下午9 54 53

$ react-native link react-native-gesture-handler --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: react-native-gesture-handler
debug Reading /Users/jabin/CreateApplication/YYHQApp_iOS_RN/ios/Podfile
info Linking "react-native-gesture-handler" iOS dependency
debug Reading /Users/jabin/CreateApplication/YYHQApp_iOS_RN/ios/Podfile
debug Adding RNGestureHandler to Pod file"
debug Writing changes to /Users/jabin/CreateApplication/YYHQApp_iOS_RN/ios/Podfile
info iOS module "react-native-gesture-handler" has been successfully linked

Thanks for posting this! I can see the code is designed to expect this line which is very weird design choice. It could be named better, like "DO NOT REMOVE. THIS IS FOR CLI POD INTEGRATION TO WORK" or so. Maybe we can squeeze the change to 0.60.

We should definitely fix it by adding a better error message. I am going to work on it now.

@zbluephoenix what is the name of your .xcodeproj and what is the target XXX do line in Podfile? This is an edge case that I would like to fix.

platform:ios,’9.0’
inhibit_all_warnings!

targetsArray = ['YYHQApp','YYHQApp_Pro']

targetsArray.each do |t|
    target t do
    pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
    end
end

YYHQApp.xcodeproj

@grabbou

Thanks! So the issue is you have an array of targets and no text marker.
I’ve just shipped a better error message to explicitly say what needs to be
done in order to make link work.

This is going to be much better when we ship autolinking soon.

Meanwhile, I believe we can close this issue since it’s expeced.

On Wed, 17 Apr 2019 at 01:38, JabinZheng notifications@github.com wrote:

platform:ios,’9.0’

inhibit_all_warnings!

targetsArray = ['YYHQApp','YYHQApp_Pro']

targetsArray.each do |t|

target t do

pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

end

end

YYHQApp.xcodeproj

@grabbou https://github.com/grabbou


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/react-native-community/cli/issues/273#issuecomment-483882195,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACWcxv1Cii0_edrZ4JXCDkiz6O6Kc9Cfks5vhl74gaJpZM4cOdxZ
.

I'm getting this error while trying to link custom fonts directory with
~react-native link ./src/resources/fonts~ (_EDIT from maintainers: this is wrong usage of link. See https://github.com/react-native-community/cli/issues/273#issuecomment-494270404_)

→ react-native link ./src/resources/fonts --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: ./src/resources/fonts
error Failed to get dependency config
debug Error: Failed to get dependency config
    at getDependencyConfig (native/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11)
    at Object.link [as func] (/native/node_modules/@react-native-community/cli/build/commands/link/link.js:97:61)
    at Promise.resolve.then (native/node_modules/@react-native-community/cli/build/cliEntry.js:152:22)
    at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:52:5)
    at Function.Module.runMain (internal/modules/cjs/loader.js:880:11)
    at internal/main/run_main_module.js:21:11

Note: we are using lerna and RN project is under the native subdirectory


react-native-cli: 2.0.1
react-native: 0.59.5

@berdyshev this is not a valid way to use link. You can only pass a valid RN module, like react-native link react-native-config. If you want to link assets, you'll need to use "rnpm" field for now, like:

"rnpm": {
  "assets": [
    "./src/resources/fonts",
  ]
}

@thymikee ok, thank you. should I run any command after that? Or just restart the react-native's packager?

Yes, you need to run react-native link after that to make linking happen

@thymikee I have pretty same issue as @berdyshev even if react-native link in action

i-surzhenko:SLM ivan.surzhenko$ react-native link --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug No package name provided, will attemp to link all possible packages.
warn Running `react-native link` without package name is deprecated and will be removed in next release. If you use this command to link your project assets, please let us know about your use case here: https://goo.gl/RKTeoc
error Failed to get dependency config
debug Error: Failed to get dependency config
    at getDependencyConfig (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11)
    at dependencies.map.dependnecy (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/linkAll.js:55:96)
    at Array.map (<anonymous>)
    at linkAll (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/linkAll.js:55:45)
    at Object.link [as func] (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/link.js:90:33)
    at Promise.resolve.then (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/cliEntry.js:152:22)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:47:5)
    at Function.Module.runMain (internal/modules/cjs/loader.js:865:11)
    at internal/main/run_main_module.js:21:11

@berdyshev I have found a workaround. react-native-asset module ( https://www.npmjs.com/package/react-native-asset ) made the deal!

The same here:
sudo react-native link react-native-gesture-handler --verbose debug Available platforms: iOS, Android debug Targeted platforms: iOS, Android debug Getting project config for iOS... debug Getting project config for Android... debug Package to link: react-native-gesture-handler error Failed to get dependency config debug Error: Failed to get dependency config at getDependencyConfig (/home/marimendes/radop-app/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11) at Object.link [as func] (/home/marimendes/radop-app/node_modules/@react-native-community/cli/build/commands/link/link.js:97:61) at Promise.resolve.then (/home/marimendes/radop-app/node_modules/@react-native-community/cli/build/cliEntry.js:152:22) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:757:11) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Yes, you need to run react-native link after that to make linking happen

I am having the same problem while installing fonts. I tried react-native-asset as suggested by @devproivansurzhenko and the fonts were still not installed.

@thymikee I followed your steps to install fonts and added
"rnpm": {
"assets": [
"./assets/fonts"
]
}

but still see same error upon react-native link
error Failed to get dependency config.

It would be great if you provided a source code somewhere (can be via private Github invitation) so we could look into that and fix it.

It's hard to debug locally w/o reproduction.

@awesomeo99 did you receive any error at react-native-asset run?

Interesting... created an RN app from scratch. react-native link works fine.

Workaround: doing react-native link works but doing ~react-native link ./assets/fonts~ (_EDIT from maintainers: this is wrong usage of link. See https://github.com/react-native-community/cli/issues/273#issuecomment-494270404_) gives the dependecy error. The downside of doing not specific link is that it will try and link all your dependencies.

react-native link ./assets/fonts --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: ./assets/fonts
error Failed to get dependency config
debug Error: Failed to get dependency config
    at getDependencyConfig (/Users/juanpabloproverbio/Desktop/Software/mo/mobilityos-passenger-app/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11)
    at Object.link [as func] (/Users/juanpabloproverbio/Desktop/Software/mo/mobilityos-passenger-app/node_modules/@react-native-community/cli/build/commands/link/link.js:97:61)
    at Promise.resolve.then (/Users/juanpabloproverbio/Desktop/Software/mo/mobilityos-passenger-app/node_modules/@react-native-community/cli/build/cliEntry.js:152:22)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
    at Function.Module.runMain (module.js:696:11)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 800.01 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
      Yarn: 1.6.0 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        Build Tools: 26.0.3, 27.0.3, 28.0.2, 28.0.3
        API Levels: 21, 22, 23, 24, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.4 AI-183.5429.30.34.5452501
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.5 => 0.59.5
    npmGlobalPackages:
      react-native-log-ios: 1.0.1

Package.json

...
"rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  },
...

Folks, using link like this: react-native link ./assets/fonts was never supported and will likely never be. Where do you get this information from? The link command accepts only an npm package name or nothing, so:

react-native link # good
react-native link react-native-config # good
react-native link @react-native-community/async-storage # good
react-native link ./some/path # bad, unsupported, it will try to use the path as npm package, that's why you get dependency error – it's not a dependency

i'm getting this error while linking the async storage

>$ react-native link @react-native-community/async-storage --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: @react-native-community/async-storage
error Failed to get dependency config
debug Error: Failed to get dependency config

This has been fixed in https://github.com/react-native-community/cli/pull/321 and now, the error message is:

error Something went wrong while linking. Reason: We couldn't find a target to add a CocoaPods dependency. Make sure that you have a "target '<nameOfYourProject>' do" line in your Podfile. Alternatively, include "# Add new pods below this line" in a Podfile where we should add linked dependencies.

I am going to lock it.

Going to be released as a part of 0.60.

FYI this was fixed in the v2 of the CLI and wasn't yet ported to 1.x branch which is used by React Native 0.59. We'd be grateful for a PR to 1.x branch with the PR mentioned by @grabbou ported

Went ahead and ported it to 1.x: https://github.com/react-native-community/cli/releases/tag/v1.9.5. Hope it's gonna be easier to track the problem now!

Was this page helpful?
0 / 5 - 0 ratings