Add dependencies and libraries
  • 05 Mar 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

Add dependencies and libraries

  • Dark
    Light
  • PDF

Article summary

Adding dependencies to your module

You can add dependencies by running yarn add within your module definition directory.

cd modules/react-native-example
yarn add react-native-share
rm yarn.lock

This adds react-native-share to your package.json dependencies property.

Adding libraries (Autolinking)

For any library that includes native code (Android, iOS, or both) you must move the dependency on the package.json to the x-dependencies property. Any x-dependencies entry is installed directly in the root package.json of your app.

This is required due to a current limitation within react-native when resolving sub-dependencies while also linking native code.

{
    "name": "@modules/example",
    "version": "1.0.0",
    "description": "",
    "private": true,
    "main": "index.js",
    "x-dependencies": {
        "react-native-share": "^10.0.2"
    }
}


Was this article helpful?