Error: Unable to resolve module ./Libraries/Components/DatePicker/DatePickerIOS

Hi,

I get this message about DatePickerIOS when I run npx expo start. It only happens on iOS (not surprisingly), I can connect with an Android phone no problem, but with my iPhone 11 on iOS 16.4.1(a) I get the error after building and bundling (which both seem to work fine). I get the error 42 times.

Our project use the managed flow and we’ve been developing it for 4 years. We’ve not had this problem before.

I’ve updated to the latest iOS and to the latest Mac OS and XCode: 14.3 (14E222b)

I’ve updated to the latest expo-cli: 6.3.7. I’ve updated to the latest react-native: 0.70.8. We’re on expo-sdk 47.0.0.

I’ve deleted my node_modules and reinstalled everything.

The weird thing is that it works fine for my colleague can run Expo on his iOS phone fine.

Thanks!

Here’s the stacktrace:

Logs for your project will appear below. Press Ctrl+C to exit.
Started Metro Bundler
iOS Bundling complete 5865ms
Error: Unable to resolve module ./Libraries/Components/DatePicker/DatePickerIOS from /Users/denishowlett/dev/jumptech/atom/node_modules/react-native/index.js:

None of these files exist:
  * node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS(.native|.native.ts|.ts|.native.tsx|.tsx|.native.js|.js|.native.jsx|.jsx|.native.json|.json)
  * node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS/index(.native|.native.ts|.ts|.native.tsx|.tsx|.native.js|.js|.native.jsx|.jsx|.native.json|.json)
  15 | import typeof ActivityIndicator from './Libraries/Components/ActivityIndicator/ActivityIndicator';
  16 | import typeof Button from './Libraries/Components/Button';
> 17 | import typeof DatePickerIOS from './Libraries/Components/DatePicker/DatePickerIOS';
     |                                   ^
  18 | import typeof DrawerLayoutAndroid from './Libraries/Components/DrawerAndroid/DrawerLayoutAndroid';
  19 | import typeof FlatList from './Libraries/Lists/FlatList';
  20 | import typeof Image from './Libraries/Image/Image';
    at ModuleResolver.resolveDependency (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:152:15)
    at DependencyGraph.resolveDependency (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/node-haste/DependencyGraph.js:264:43)
    at Object.resolve (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/lib/transformHelpers.js:170:21)
    at resolveDependencies (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/DeltaBundler/graphOperations.js:466:33)
    at processModule (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/DeltaBundler/graphOperations.js:232:31)
    at addDependency (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/DeltaBundler/graphOperations.js:361:18)
    at async Promise.all (index 1)
    at processModule (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/DeltaBundler/graphOperations.js:279:3)
    at addDependency (/Users/denishowlett/dev/jumptech/atom/node_modules/metro/src/DeltaBundler/graphOperations.js:361:18)
    at async Promise.all (index 1)
iOS Running app on iPhone
Error: Unable to resolve module ./Libraries/Components/DatePicker/DatePickerIOS from /Users/denishowlett/dev/jumptech/atom/node_modules/react-native/index.js:

None of these files exist:
  * node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS(.native|.native.ts|.ts|.native.tsx|.tsx|.native.js|.js|.native.jsx|.jsx|.native.json|.json)
  * node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS/index(.native|.native.ts|.ts|.native.tsx|.tsx|.native.js|.js|.native.jsx|.jsx|.native.json|.json)

So I’ve found a work around for now. I found this issue Xcode 14.3 - Error: Unable to resolve module ./Libraries/Components/DatePicker/DatePickerIOS · Issue #36794 · facebook/react-native · GitHub which suggested creating a metro.config.js file (we didn’t have one). I pasted in the contents and now it runs on iOS.

The metro.config.js I now have is as follows:

const { getDefaultConfig } = require('expo/metro-config');

const config = getDefaultConfig(__dirname);

config.server = {
  ...config.server,
  rewriteRequestUrl: url => {
    if (!url.endsWith('.bundle')) {
      return url;
    }
    // https://github.com/facebook/react-native/issues/36794
    // JavaScriptCore strips query strings, so try to re-add them with a best guess.
    return url + '?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true';
  }
};
module.exports = config;
2 Likes