Working with the codebase
Manage Dependencies

Manage Dependencies

In NativeExpress projects, we recommend using npx expo install for installing dependencies. This command is designed to work with the package manager configured in your project, which is yarn for NativeExpress.

Why use npx expo install?

npx expo install is a smart package manager wrapper that provides several benefits:

  • It automatically chooses versions of packages that are compatible with your current Expo SDK version.
  • It can patch packages that are known to have issues with Expo.
  • It maintains consistency across Expo projects.
  • It works with your project's configured package manager (npm, yarn, or pnpm). NativeExpress uses yarn.

Install a Package

To install a package in NativeExpress, use the following command:

npx expo install <package-name>

This command will use the appropriate package manager for your project.

Remove a Package

To remove a package, you should use your project's configured package manager directly. For example, if your project uses yarn:

yarn remove <package-name>

Update a Package

To update a package, you can use npx expo install with the latest version:

npx expo install <package-name>@latest

Check for Outdated Packages

To check for outdated packages in your project:

npx expo doctor --fix-dependencies

This command will check your dependencies and suggest updates if available. The --fix-dependencies flag will automatically update packages to their latest Expo-compatible versions.

Best Practices

  1. Always use npx expo install for adding new packages to ensure compatibility with Expo.
  2. For removing packages, use your project's configured package manager (npm, yarn, or pnpm).
  3. Regularly check for outdated packages and update them to keep your project secure and up-to-date.
  4. After installing or updating packages, test your application thoroughly to ensure everything still works as expected.
  5. If you encounter any issues after updating packages, try clearing your Metro bundler cache:
npx expo start --clear

Remember, managing dependencies correctly is crucial for maintaining a stable and efficient NativeExpress project. Always be cautious when adding new packages or updating existing ones, and make sure to test your application after any changes.