Expo Web: Module not found "Can't resolve ../Utilities/Platform"

Expo SDK: 41
react-native-web version: 0.17.1

I’m having a problem building my project for web. Seems to be a problem with React Native, as a relative import in the react-native node module is failing. my .babelrc is:

{
    "plugins": [
        
        [
            "module-resolver",
            {
                "root": [
                    "./"
                ],
                "alias": {
                    "components": "./src/components",
                    "networking": "./src/networking",
                    "style": "./src/style",
                    "types": "./src/types",
                    "app": "./src",
                    "theme": "./src/Theme"
                }
            }
        ]
    ]
}

My webpack config is:

const expoConfig = require('@expo/webpack-config');
const path = require('path');

module.exports = async function(env, argv) {
  const config = await expoConfig(env, argv);
  config.resolve = {
    alias: {
        "components": path.resolve(__dirname, "src/components"),
        "networking": path.resolve(__dirname, "src/networking"),
        "style": path.resolve(__dirname, "src/style"),
        "types": path.resolve(__dirname, "src/types"),
        "app": "./src",
        "theme": path.resolve(__dirname, "src/Theme")
    }
  };
  return config;
}

And the full error is:

Failed to compile.
/Users/x/Desktop/x/node_modules/react-native/Libraries/Image/AssetSourceResolver.js
Module not found: Can't resolve '../Utilities/Platform' in 'project/path/node_modules/react-native/Libraries/Image'

No idea what to do here, other than downgrade my expo SDK and hope it works. The weird thing is, I’m not even using an Image anywhere in my app

Welcome to the long long tail of “Module not found “Can’t resolve …/Utilities/Platform” issue : https://github.com/expo/web-examples/issues/73 (opened since Feb 6th 2020)

So yes you’re not using Image, but another module does, the question is “how to find which one” :wink:

You can try the last script fix-for-rn-rnw.js - I did not test it yet …

If you find a repeatable solution, feel free to post it here and in the issue #73

1 Like

@lc3t35 The scripts did not solve the issue for me :neutral_face:

@iway1 Did you find a solution yet?

1 Like