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
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.
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
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?
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.
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.