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

React Native SDK broken. Unable to resolve "thirdweb/pay" from "node_modules/@thirdweb-dev/sdk/dist/thirdweb-dev-sdk.cjs.dev.js" #2807

Open
jrhe opened this issue Apr 18, 2024 · 30 comments
Assignees
Labels
bug Something isn't working

Comments

@jrhe
Copy link

jrhe commented Apr 18, 2024

If I try installing adding react-native sdk, either in a bare react-native project or in an expo project I get the following error. The error happens as soon as you add ThirdWebProvider component to your app.

ERROR  [Error: undefined Unable to resolve module thirdweb/pay from /Users/jon/repos/github.com/jrhe/thirdweb_bare_react_native_test/node_modules/@thirdweb-dev/sdk/dist/thirdweb-dev-sdk.cjs.prod.js: thirdweb/pay could not be found within the project or in these directories:
  node_modules/@thirdweb-dev/sdk/node_modules
  node_modules
  111 | require('uuid');
  112 | require('thirdweb');
> 113 | require('thirdweb/pay');
      |          ^
  114 | require('thirdweb/utils');
  115 | require('fast-deep-equal');
  116 | require('./marketplace-bc46f8c3.cjs.prod.js');]

There are also other users on discord having this issue: https://discord.com/channels/834227967404146718/1229386961018425444

I have tried different versions of expo, thirdweb's packages, and react-native without luck.

@jnsdls
Copy link
Member

jnsdls commented Apr 18, 2024

hi @jrhe we are working on this one, in the meantime you should be able to solve this by temporarily pinning @thirdweb-dev/react-native to version 0.73.1

@jnsdls jnsdls self-assigned this Apr 18, 2024
@jnsdls jnsdls added the bug Something isn't working label Apr 18, 2024
@web3rev
Copy link

web3rev commented Apr 18, 2024

Also running into the same issue here. Looking forward for it to be resolved soon 👍

@minhthuong031103
Copy link

Hi @jnsdls, I have tried to downgrade to older version but i don't know why it still has the same issue.

@jnsdls
Copy link
Member

jnsdls commented Apr 23, 2024

Hi @jnsdls, I have tried to downgrade to older version but i don't know why it still has the same issue.

can you try deleting your node_modules and reinstalling? most likely you have ended up with a cached dependency of some sort


We're targeting a minimal version of the react-native overhaul (first version) by end of this week or early next week. It will likely come with less pre-configured wallet support out of the box initially (since the wallet libraries are (mostly) the things that force us into bad DX (having to eject out of expo, installing tens of polyfills etc)

@johnernest02-EYGDS
Copy link

hi @jrhe we are working on this one, in the meantime you should be able to solve this by temporarily pinning @thirdweb-dev/react-native to version 0.73.1

@thirdweb-dev/react-native@0.73.1 does not exist. I did try 0.7.31 but it still has the same issue. Or I may have not cleaned, deleted builds and stuff enough? Though I did verify that is the package being used

@minhthuong031103
Copy link

@thirdweb-dev/react-native@0.73.1 does not exist. I did try 0.7.31 but it still has the same issue. Or I may have not cleaned, deleted builds and stuff enough? Though I did verify that is the package being used

Yeah I also think there maybe some mistake here, I have tried 0.7.31 -> 0.5.xx but it still has the same error, also tried to create a new React Native Project form scratch too but still the same.

@johnernest02-EYGDS
Copy link

I will be trying a few more versions and try to track it down

@avantmarketing1
Copy link

I reverted to 0.7.31 and the issue went away:

"@thirdweb-dev/react-native": "^0.7.31",
"@thirdweb-dev/react-native-compat": "^0.7.31",

Maybe delete the cache and rebuild.

I've had a lot of issues with the React Native SDK.

I will probably put my mobile app on hold until the overhaul is available.

The v5 React SDK is so much better.

@mbalazy
Copy link

mbalazy commented Apr 26, 2024

While waiting for the fix i tried this (little hacky) solution:

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
const extraNodeModules = require('node-libs-browser')

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = {
  resolver: {
    extraNodeModules,
    resolveRequest: (ctx, moduleName, platform) => {
      if (moduleName.startsWith('thirdweb')) {
        return {
          filePath: `${__dirname}/node_modules/thirdweb/dist/esm/`,
          type: 'sourceFile',
        }
      }

      // Optionally, chain to the standard Metro resolver.
      return ctx.resolveRequest(ctx, moduleName, platform)
    },
  },
}

module.exports = mergeConfig(getDefaultConfig(__dirname), config)

unfortunately, I got another error Invariant Violation: Unexpectedly escaped traversal but maybe it's just because my stack/setup, you can try it on your setups guys and wait till official fix.

@minhthuong031103
Copy link

minhthuong031103 commented Apr 27, 2024

unfortunately, I got another error Invariant Violation: Unexpectedly escaped traversal but maybe it's just because my stack/setup, you can try it on your setups guys and wait till official fix.

I have tried your method but also get the error like you, my project is new set up, sadly right now i cant find any way to run thirdweb in my react native project with any version

@johnernest02-EYGDS
Copy link

I have added the react-native-compat library as well, but then it looked for different other packages that I added. At the end of it, it couldn't find the "Button" component from react-native itself.

@theweb3kid
Copy link

hey, was anyone able to find any resolution to this?

@web3rev
Copy link

web3rev commented May 3, 2024

Don't think so @theweb3kid . Until this bug is resolved, there doesn't seem to be any way to make thirdweb work with React Native.

@Abdullah098765
Copy link

Hay Guys are you still facing this issue if you got it please share

@web3rev
Copy link

web3rev commented May 7, 2024

same issue here. Still waiting for fix. Thanks.

@avantmarketing1
Copy link

We're targeting a minimal version of the react-native overhaul (first version) by end of this week or early next week. It will likely come with less pre-configured wallet support out of the box initially (since the wallet libraries are (mostly) the things that force us into bad DX (having to eject out of expo, installing tens of polyfills etc)

Is there any update on this? I only need inApp wallet and smart wallet support.

@joaquim-verges
Copy link
Contributor

we released a patch 0.8.0 of the @thirdweb-dev/react-native package which should resolve this issue - can you all confirm?

In the meantime, we're working on a completely revamped react native package based on the v5 typescript/react web SDK, will be more performant and much lighter than the current one - stay tuned for updates!

@lsw-1
Copy link

lsw-1 commented May 15, 2024

Still not working for me unfortunately, I removed node_modules and did a metro reset of the cache. Latest working version for me is 0.7.21

@avantmarketing1
Copy link

Still getting the same error. I can fix it by removing all references to 'thirdweb', 'thirdweb/pay' and 'thirdweb/utils'. And removing all the functions associated with 'getBuyWithCrypto'.

@minhthuong031103
Copy link

Still getting the error
image

@jrhe
Copy link
Author

jrhe commented May 16, 2024

Ended up switching to privy as although I got it running after a load of time and fiddling, I then ran into further errors.

@joaquim-verges
Copy link
Contributor

hey all, we've been hard at work making v5 work in react native projects.

We've got it mostly working, just working on docs now and putting in the last finishing touches.

will post the docs links here as soon as they're up

@theweb3kid
Copy link

Kudos for the hard work, team! Let us know if you need any help with testing. We're excited to integrate as soon as possible!

@joaquim-verges
Copy link
Contributor

Latest release is out V5.23.0 now works with react native with the additional @thirdweb-dev/react-native-adapter and a few other dependencies.

Appart from installation, everything works the same as on the web with the same imports.

Docs: https://portal.thirdweb.com/typescript/v5/react-native

Demo repo: https://github.com/thirdweb-example/expo-starter

Let us know what you think!

@avantmarketing1
Copy link

Thanks for the update.

My react native app uses aws-amplify@6.0.20

I'm getting this error installing thirdweb:
Conflicting peer dependency: aws-amplify@5.3.18

Is it possible to use thirdweb with the latest version of amplify?

@avantmarketing1
Copy link

Also getting this error when building on android:
Cannot locate tasks that match ':coinbase-wallet-mobile-sdk:assembleDebug' as project 'coinbase-wallet-mobile-sdk' not found in root project.

@joaquim-verges
Copy link
Contributor

Thanks for the update.

My react native app uses aws-amplify@6.0.20

I'm getting this error installing thirdweb:
Conflicting peer dependency: aws-amplify@5.3.18

Is it possible to use thirdweb with the latest version of amplify?

It's on our todo lost to upgrade to v6, but it's a hard dependency of react-native-adapter so it shouldn't cause issues? What error do you see?

@joaquim-verges
Copy link
Contributor

Also getting this error when building on android:
Cannot locate tasks that match ':coinbase-wallet-mobile-sdk:assembleDebug' as project 'coinbase-wallet-mobile-sdk' not found in root project.

The V5 SDK does not have/use Coinbase wallet SDK yet. Might need to remove it from your project

@avantmarketing1
Copy link

I managed to get the App to build by converting my React Native CLI project to an Expo project.

I followed the expo-starter example to create a custom wallet connect button, but I'm receiving these errors when I click the inApp sign in buttons:

ERROR TypeError: Cannot read property 'loginWith' of undefined, js engine: hermes
ERROR [TypeError: Cannot read property 'InAppNativeConnector' of undefined]

The InApp buttons show a continuous loading state and fail to connect.
The MetaMask button successfully connects but still shows the errors.

@lsw-1
Copy link

lsw-1 commented May 27, 2024

Latest release is out V5.23.0 now works with react native with the additional @thirdweb-dev/react-native-adapter and a few other dependencies.

Appart from installation, everything works the same as on the web with the same imports.

Docs: https://portal.thirdweb.com/typescript/v5/react-native

Demo repo: https://github.com/thirdweb-example/expo-starter

Let us know what you think!

Thanks for the update, the demo app works well for me except for web. Will that be fixed?

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

No branches or pull requests