Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble getting "expo-router" installed + starting #97

Closed
owenduncansnobel opened this issue Jul 2, 2023 · 4 comments
Closed

Trouble getting "expo-router" installed + starting #97

owenduncansnobel opened this issue Jul 2, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@owenduncansnobel
Copy link

Description of the bug

Is there an example of getting "expo-router" working with this repo? I have been trying to add it but I am getting errors when trying to install it.

@owenduncansnobel owenduncansnobel added the bug Something isn't working label Jul 2, 2023
@tichopad
Copy link
Contributor

Hey @owen-duncan-snobel I went down this rabbit hole as well.

I've finally been able to somewhat figure it out by:

  1. Deleting the following setting from "metro.config.js":
// #3 - Force resolving nested modules to the folders below
config.resolver.disableHierarchicalLookup = true;
  1. Instead of using "main": "expo-router/entry" in "package.json", creating an "index.js" file and using that as the main entry.
  2. Adding import "expo-router/entry" to the "index.js".

The main issue I've been having is Metro not being able to resolve "expo-router/entry". I guess the resolution process is different for imports and the "main" field in package.json. It also doesn't seem to work with hierarchical lookup disabled.

I can provide you with an example project setup later if you want. Btw I'm using the official tabs template for my app workspace and I'm also using pnpm with hoisted node-linker (as this repo does).

@owenduncansnobel
Copy link
Author

owenduncansnobel commented Jul 11, 2023

I can provide you with an example project setup later if you want. Btw I'm using the official tabs template for my app workspace and I'm also using pnpm with hoisted node-linker (as this repo does).

Ya if you were able to post an example of the setup later that would be amazing!

@tichopad
Copy link
Contributor

@owen-duncan-snobel Sorry it took so long. I got distracted by Diablo 4 lol.

Here you go https://github.com/tichopad/expo-monorepo-example/tree/main/apps/mobile-with-router.

It should work out of the box. Although I haven't tested EAS Build.

@byCedric
Copy link
Owner

byCedric commented May 9, 2024

Sorry it took a while! Next time, do ping me on Twitter @cedric_dev.

Yep, @tichopad is right, disableHierarchicalLookup shouldn't be disabled anymore. This used to be required due to various issues in both the native layers of React Native, as well as Metro. These have now all been fixed, and our docs has been updated to mention this too:

image

I also updated this monorepo to use Expo SDK 51, and removed this property. Hope this helps!

@byCedric byCedric closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants