clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.05k stars 237 forks source link

@clerk/clerk-expo "unable to resolve dependency tree" #3716

Closed juliuslissau closed 2 months ago

juliuslissau commented 2 months ago

Preliminary Checks

Reproduction

https://github.com/juliuslissau/test-app

Publishable key

unnecessary

Description

Steps to reproduce:

  1. Step 1: npx create-expo-app@latest test-app --template blank
  2. Step 2: npm install @clerk/clerk-expo

Expected behavior: @clerk/clerk-expo should install.

Actual behavior:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: test-app@1.0.0
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   react@"18.2.0" from the root project
npm ERR!   peer react@">=18" from @clerk/clerk-expo@1.2.6
npm ERR!   node_modules/@clerk/clerk-expo
npm ERR!     @clerk/clerk-expo@"*" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.3.1" from react-dom@18.3.1
npm ERR! node_modules/react-dom
npm ERR!   peer react-dom@">=18" from @clerk/clerk-expo@1.2.6
npm ERR!   node_modules/@clerk/clerk-expo
npm ERR!     @clerk/clerk-expo@"*" from the root project

Note: It somehow works if you run npx create-expo-app@latest test-app without --template blank, but I don't understand why and it just installs a lot of web related packages which it seems Clerk doesn't support anyway (Currently the @clerk/expo SDK only supports mobile app output. - https://clerk.com/docs/quickstarts/expo)

Environment

System:
    OS: macOS 14.3
    CPU: (8) arm64 Apple M2
    Memory: 99.84 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 17.3
  npmPackages:
    @babel/core: ^7.20.0 => 7.24.9 
    expo: ~51.0.20 => 51.0.20 
    expo-status-bar: ~1.12.1 => 1.12.1 
    react: 18.2.0 => 18.2.0 
    react-native: 0.74.3 => 0.74.3
LekoArts commented 2 months ago

Hi, thanks for the issue!

The error message is already telling you what's wrong:

npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.3.1" from react-dom@18.3.1
npm ERR! node_modules/react-dom
npm ERR!   peer react-dom@">=18" from @clerk/clerk-expo@1.2.6

Your project is missing the dependency react-dom. It's defined as a peerDependency (read: I needs to be installed) here: https://github.com/clerk/javascript/blob/944bb2e23ccd6187bf1ad623b48629e8c2b71442/packages/expo/package.json#L64

juliuslissau commented 2 months ago

Thanks for clarifying a bit more

I already tried install react-dom, just doing npm i react-dom gives the same error.

Then running npm i react-dom@18.2.0 allows installing react-dom, but then the error with clerk persists which I didn't understand.

Now after your comment assuring it was related to react-dom, I tried npx expo install react-dom and npx expo install @clerk/clerk-expo which then made everything fit together. Thanks and sorry about the confusion :)

You might wanna add this to your documentation though. Seems like an good thing to have in the beginning of this article.

LekoArts commented 2 months ago

Glad that you got it to work 👍

Our quickstart links to https://docs.expo.dev/tutorial/create-your-first-app/ in the "Before you start" section and they have this step: https://docs.expo.dev/tutorial/create-your-first-app/#install-dependencies

I think that should cover it 😊 Support for Expo Web is also coming soon!

Rakhilpr96 commented 3 weeks ago

I resolved it by changing "react-dom": "^18.2.0" to "react-dom": "18.2.0"