Android can't find app source code

After ejecting my app (with expo 38) and building the app for android, it can’t find the source code of the app.

The code structure looks like this:

android/
ios/
src/
App.js => actual app code
index.js => entry point

index.js imports App.js. App.js import several files from src.

Running npm start && npm run android it builds the app correctly and it starts on my simulator. However, it can’t find the modules placed in src/. The server returns the following message:
[Mon Jul 20 2020 19:19:02.983] BUNDLE ./index.js

error: Error: Unable to resolve module src/HOC/DataLoader.jsxfromApp.js: src/HOC/DataLoader.jsx could not be found within the project.

I’ve solved my own problem.
The issue here were the extension of my module (.jsx) and the metro resolver.
By adding the following values to metro.config.js the issue was fixed:

module.exports = {
  ...
  resolver: {
    sourceExts: ['js', 'jsx', 'ts', 'tsx']
  },
};

It would be nice if on eject, expo would generate this file with default values such as jsx and ts

1 Like