Utilities/Platform missing for react-native

Viewed 11889

I trying to run expo-cli in browser mode.

But there is the error:

Module not found: Can't resolve '../../Utilities/Platform' in '.../node_modules/react-native/Libraries/Core/Timers'.

I tried also to look manually for this module but no luck.

What can I do to make expo client works in web browsers?

3 Answers

You can also config your webpack. You can use 'expo customize:web'. This will install @expo/webpack-config as development dependency an create a webpack.config.js.

You can define aliases on this configuration like this:

const createExpoWebpackConfigAsync = require('@expo/webpack-config')

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(env, argv)
  config.resolve.alias['../Utilities/Platform'] =
    'react-native-web/dist/exports/Platform'
  return config
}

This should resolve your issue

As for me, If you experience this error and you have done re-install on your packages and the error still remain, Now check all your import, there must be something your are suppose to import form react-native that you are importing from somewhere else if you can find this this error will be fixed what you can do is to identify the actual wrong import

for me I do "import Pressable from "reactnative/Libraries/Components/Pressable/Pressable" instead of
import {Pressable } from "react-native";

Related