Skip to content

[Bug]: expo-constants dependency breaks non-Expo React Native projects #931

@zaid0088

Description

@zaid0088

Describe the bug

🐛 Bug Report

Summary

After upgrading my project from React Native 0.72.x to 0.73.x, my app started crashing with the following error:

Error: Unable to resolve module expo-constants expo-constants could not be found within the project or in these directories: node_modules/react-native-date-picker/node_modules node_modules ../../../../node_modules

The issue seems to be caused by a reference to expo-constants within the react-native-date-picker dependency or one of its internal files.

Note: This was working perfectly fine before the React Native upgrade to 0.73.

Environment

  • React Native version: 0.73.6
  • react-native-date-picker version: 5.0.4
  • Project type: React Native CLI (not using Expo)
  • Platform: Android (likely affects iOS as well)

Thank you for your work on this great library!

Expected behavior

The library should not depend on Expo-only modules like expo-constants, or it should handle them conditionally. Projects that do not use Expo should not be required to install Expo packages.

To Reproduce

1. Start with a working React Native CLI app using version 0.72.x and `react-native-date-picker`
2. Upgrade React Native to 0.73.x
3. Rebuild the app
4. Encounter error regarding missing `expo-constants` module

Operating System

  • Android
  • iOS

React Native Version

0.73.6

Expo Version (if applicable)

Not Using expo

react-native-date-picker version

5.0.4

React Native Architecture

  • Old Architecture (Paper)
  • New Architecture (Fabric)

Relevant log output

Error: Unable to resolve module expo-constants from /Users/app/node_modules/react-native-date-picker/src/installationError.js: expo-constants could not be found within the project or in these directories:
  node_modules/react-native-date-picker/node_modules
  node_modules
  ../../../../node_modules
  41 |   try {
  42 |     // @ts-ignore
> 43 |     require('expo-constants').default
     |              ^
  44 |     return messages[Platform.OS].expo
  45 |   } catch (e) {
  46 |     return messages[Platform.OS].nonExpo

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions