t3-oss / create-t3-turbo

Clean and simple starter repo using the T3 Stack along with Expo React Native
https://turbo.t3.gg
MIT License
4.75k stars 407 forks source link

Expo App Doesn't Load on Android #91

Closed deshumake closed 1 year ago

deshumake commented 1 year ago

I created a new repo from this template, followed the quickstart guidelines, and got this error from expo:

Error: Unable to resolve module ./index.ts from C:\Users\...\apps\expo/.: 

None of these files exist:
   * index.ts(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)
   * index.ts\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)
     at ModuleResolver.resolveDependency (C:\Users\...\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:153:15)
     at DependencyGraph.resolveDependency (C:\Users\...\node_modules\metro\src\node-haste\DependencyGraph.js:276:43)        
     at C:\Users\...\node_modules\metro\src\lib\transformHelpers.js:171:21
     at Server._resolveRelativePath (C:\Users\...\node_modules\metro\src\Server.js:1256:12)
     at async Server.requestProcessor [as _processBundleRequest] (C:\Users\...\node_modules\metro\src\Server.js:529:37)     
     at async Server._processRequest (C:\Users\...\node_modules\metro\src\Server.js:449:9)

index.ts is definitely in the expo home directory.

What I've tried:

  1. Searching up different issues related to "Expo", "Unable to resolve module", and "None of these files exist"
  2. Changing the value of "main" in expo's package.json
  3. Creating a new t3-turbo repo using a different laptop, and a different phone (Do not have a mac, or iPhone)
  4. Creating a brand new expo app using create-expo-app, but then running pnpm install in it.

Results:

Is anyone else able to reproduce this issue? Any ideas about what may be wrong?

juliusmarminge commented 1 year ago

I don't have an android to test with unfortunately.

Anyone else whose able to repro this?

juliusmarminge commented 1 year ago

seems related to #32

deshumake commented 1 year ago

It does look very related to #32.

index.ts\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)

One thing I noticed: if you're currently running pnpm dev, and then add a dot file in the same directory as index.ts, the build progress bar appears for an instant, and another error 'unable to resolve "expo" from index.ts' appears. This error doesn't appear from a fresh run though after adding that file, so this is probably nothing.

Because of this line, I thought that "main" could also take in a folder, so I tried replacing "index.ts" with "src", and moved index.ts into the source folder. It still gives a similar error though.

src\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)

And I feel like this makes less sense than the error before, because the first error seems to be saying that there wasn't an index.ts.ts file, but now it looks like it's actually looking for a normal index.ts file, and that's definitely there in the src dir

juliusmarminge commented 1 year ago

Maybe try downgrading Expo sdk

deshumake commented 1 year ago

Looks like the issue is the version of react and shopify. When I run expo, there is this warning:

Some dependencies are incompatible with the installed expo version:
  @shopify/flash-list@1.4.0 - expected version: 1.3.1
  react@18.2.0 - expected version: 18.1.0
  react-dom@18.2.0 - expected version: 18.1.0
  react-native@0.71.0-rc.0 - expected version: 0.70.5
Your project may not work correctly until you install the correct versions of the packages.
Install individual packages by running npx expo install @shopify/flash-list@1.3.1 react@18.1.0 react-dom@18.1.0 react-native@0.70.5

I assumed that since these versions were in the repo, and no one had issues, that this wouldn't be the problem. After you suggested downgrading, I ran the command in the last line to downgrade these versions, and the app runs now, but more warnings are given:

../..                                    |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date
 WARN  deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
 WARN  deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
 WARN  deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
 WARN  deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
 WARN  deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
 WARN  deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated                                                                                            
 WARN  deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0

Should these warnings just be ignored? Should the versions not actually be downgraded?

juliusmarminge commented 1 year ago

Yes these warnings can be ignored. Everything works as expected with them.

Your issue is not related to these warnings

deshumake commented 1 year ago

Does this versioning not provide any issues for ios?

cervantes-x commented 1 year ago

I am experiencing the same issue. I managed to get Expo Go running again by changing react to version 18.1.0.

As a side effect I'm now unable to create a build. I'm getting the following error message during the gradlew step:

[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * Where:
[stderr] Build file '/home/expo/workingdir/build/node_modules/expo/android/build.gradle' line: 9
[stderr] * What went wrong:
[stderr] A problem occurred evaluating project ':expo'.
[stderr] > Cannot invoke method multiply() on null object
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * Where:
[stderr] Build file '/home/expo/workingdir/build/node_modules/expo/android/build.gradle' line: 79
[stderr] * What went wrong:
[stderr] A problem occurred configuring project ':expo'.
[stderr] > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 1m 54s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

I'm not sure why but when I change all the react versions in the monorepo to use 18.1.0 the builds start to work again. I feel like there is something wrong with the configuration not fetching the packages from the correct location.

jimboboliver commented 1 year ago

Running npx expo-cli doctor --fix-dependencies in the expo app directory fixes this for me, but I have only tested the expo app with Android.

juliusmarminge commented 1 year ago

Running npx expo-cli doctor --fix-dependencies in the expo app directory fixes this for me, but I have only tested the expo app with Android.

I hope Expo SDK 48 isn't too far out so that we can use React 18.2 with full support - although I haven't noticed it not working as it is now.

juliusmarminge commented 1 year ago

Closing as completed. I'll leave the React 18.2 in there for now as it seems to work for most (you are the first one who have reported an issue related to this).

If someone else comes across this in the future, try the solution above and downgrade to the officially supported versions - Expo SDK 48 should introduce official support for these which will let us suppress these warnings for good!

deshumake commented 1 year ago

Sounds good. Thanks for the help!

pencilcheck commented 1 year ago

The command has been updated to npx expo-doctor And running this in the expo somehow fixed it for me when trying to run on Android emulator, even though the command said there is nothing wrong with the repo. lol