Trying to use Expo in a monorepo

#1

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
hashAssetFiles:1243:3
#2

Hi-

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?

#3

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.

#4

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

#5

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

https://docs.expo.io/versions/v17.0.0/guides/configuration.html#entrypoint

https://docs.expo.io/versions/v17.0.0/guides/configuration.html#nodemodulespath

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.

#6

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

#7

Hi

I’ve created a boilerplate for using expo with lerna, maybe it might be useful for you. https://github.com/Fried-Chicken/expo-monorepo