MetaMask / metamask-sdk

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.
https://metamask.io/sdk/
Other
154 stars 93 forks source link

[Bug]: sdk-react-native, Error resolving module `@metamask/sdk-react-native` #929

Closed Thormeard closed 1 week ago

Thormeard commented 1 month ago

SDK

React-Native

Provide environment information

react-native: 0.74.2 iOS 17.3.1 @metamask/sdk-react-native: 0.3.1

MetaMask SDK Version

"@metamask/sdk-react-native": "^0.3.1"

MetaMask Mobile app Version

-

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Having this error with the latest 0.3.1 version of sdk-react-native. Rolling back to 0.3.0 fixes the issue.

Both android and ios. Reproducible with example https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples/reactNativeSdkDemo

Similar issue in sdk-react from last year https://github.com/MetaMask/metamask-sdk/issues/596

[Error: InternalError Metro has encountered an error: While trying to resolve module `@metamask/sdk-react-native` from file `./src/components/MetaMask/MetaMaskConnector.js`, the package `./node_modules/@metamask/sdk-react-native/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`./node_modules/@metamask/sdk-react-native/index`. Indeed, none of these files exist:

  * ./node_modules/@metamask/sdk-react-native/index(.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * ./node_modules/@metamask/sdk-react-native/index/index(.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx): ./node_modules/metro/src/node-haste/DependencyGraph.js (243:17)

Expected Behavior

No issues when starting an example app

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

No response

To Reproduce

omridan159 commented 1 month ago

Hi @Thormeard,

Thank you for reporting this issue.

Could you please try running the following commands after updating the package?

cd ios && pod install --repo-update

I was unable to reproduce the issue after performing these steps and running pod install on the example project. Please let me know if this resolves the issue for you.

omridan159 commented 1 month ago

@Thormeard Additionally, I have updated the example in our repo to version 0.3.1 in this PR. Please check it out and try to run it again after it gets merged.

Thormeard commented 1 month ago

@omridan159

Thanks for the response.

I tried to do pod install with repo update flag, nothing changed.

Tried on another machine (with linux) and with android build - same issue. Tried to start metro server with --reset-cache flag as well.

Also tried to delete node_modules and do yarn couple of time just to be sure.

omridan159 commented 1 week ago

Hey @Thormeard, this issue should be resolved in the latest version: v0.3.5.

Could you please give it another try and let us know how it goes? 🙏