Trying to use Expo in a monorepo

I’m trying to setup a project with Expo. I’ve tried both the Expo XDE and create-react-native-app but I always end up with the same error.

What I’m trying to do is to create the project in a folder src/js/src/mobile/<project files go here>, but then I want to run it from the root of my project.
I’ve tried putting the main key in my package.json to point to src/js/src/mobile/App.js (main.js when using Expo XDE) and moving app.json (or exp.json) to the root, configuring it to have the entryPoint set to this same file and setting up all the proper babel presets.

The error I get is always the same

Unhandled JS Exception: TypeError

global code


Why do you want to run it from the root of your project? So you can include files under src/ but not under src/mobile/ or some other reason?

Where I work we have a monorepo where the tooling depends on running commands from the root. We only have a single package.json with all of our dependencies and then tooling to allow us to only install packages/run dev environment/run test/etc for a specified project.

Could you write a simple bash script in your root directory that just cd’s into your project subdirectory and runs exp?

I think you could probably hack something together using some of these options:

and maybe something else and maybe a couple lines of a bash script or something like that.

I don’t have a specific concrete solution for your specific case but try looking at those docs, and I think you’ll be able to get something together that works eventually.

Yeah, I could write a bash script, but I’d rather use what we already have since we have a lot of dependencies around only having a single package.json. It runs like this, there’s just some linking from the root to my directory that is not connected somehow.

I did the same in a clean project, and that worked fine, so I guess I have some package somewhere polluting the environment.

It might actually be the nodemodulespath that is missing in my configuration. I’ll try that out


I’ve created a boilerplate for using expo with lerna, maybe it might be useful for you.

Hi @arnarthor

You could see my blog post =>

Hope it can help you

Is expo-yarn-workspaces still necessary? Now that yarn supports a nohoist option I’m able to keep the dependencies within the project. What else does that package do?

I’ve not looked into monorepos, but in the How to set up EAS Build with a monorepo docs they say:

  • If you are building a managed project in a monorepo , please refer to byCedric/eas-monorepo-example for a working example. You will need to set up symlinks with expo-yarn-workspaces in order to ensure that Expo module packages can be resolved. A better solution for this is in progress and should be available by SDK 43.

That process is pretty invasive and seems fragile.

I was able to get most of the way there simply by using yarn’s “nohoist” option. The only issue is the imported components can’t seem to import anything. I’ve narrowed this down to a metro configuration problem, where the resolver doesn’t look at the projects node_modules directory when resolving imports for the imported modules.

I don’t know what they’re planning for SDK 43, but given their past schedule for SDK releases it should be released around the end of this month. I’m a little surprised they haven’t released a beta version yet.

@bycedric is the “better solution” still planned for SDK 43?

Count me in on helping beta test this feature. I need to be able to build multiple variants of my apps and need to share components between them to do that.

Are you using app.config.js? Do you even need a monorepo for this sort of thing? :slight_smile:

I don’t think I can do this with config. Maybe ‘variant’ is a bad term. I have different constituents for my application that have varying needs (sort of like the difference between Uber’s driver app and its rider app), and each one is different app in the stores, but I want to share components between them.

Also, I share some JS code with my web app. My expo apps are workspaces within my web app’s monorepo, so they can pull in shared libraries from it’s parent.

So my monorepo root is my node/express app, which serves up apis as well as the bundle for my webpack-built react app. My expo app lives in the monorepo mainly to utilized shared components.

OK, I see. I thought you might be referring to a white-label app.

I wish it was that easy. :slight_smile:

1 Like

Here’s a link to the PR. Apparently only Android so far and no docs yet:

Thanks, I was able to extract enough from that PR to get my environment working, but it’s a hack until 43 is out.

1 Like