-
Notifications
You must be signed in to change notification settings - Fork 138
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
Error : the package F:\xyz\hashgraphsdk\node_modules\@hashgraph\sdk\package.json
was successfully found. However, this package itself specifies a main
module field that could not be resolved (F:\xyz\hashgraphsdk\node_modules\@hashgraph\sdk\lib\index.cjs
. Indeed, none of these files exist:
#312
Comments
can you please look into theis issue, we are getting an error when trying to integrate with react-native project |
I'm having the same problem while trying to update the SDK for my mobile wallet, which also uses react-native. |
Ok, so when I added cjs to my sourceExts in the resolver in metro.config.js, I got past that one error: resolver: { The server still gives me this warning: warn Package @hashgraph/sdk has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /Users/robertkainz/Development/wallawallet-mobile/Ledgerama/node_modules/@hashgraph/sdk/package.json and additionally the app crashes on startup saying it needs http2 and child_process. The problem now appears to be that at least child_process expects to be run in a node server context but React Native is browser-based so it is not compatible. It appears to be me that this version of the Hedera SDK is not supported in a React Native mobile application. Can someone please confirm? Has anyone successfully used the 2.0.11 Hedera JS-SDK in a React Native mobile app to communicate directly with Hedera nodes (not grpc proxy nodes)? |
Note, we are looking into this, but it isn't clear on how to fix this issue for react native. We have tried doing the simple task of adding |
Any update on React Native support for the JS SDK? Is this the right issue to track for it? |
This is the right issue to track, but we haven't made much progress here unfortunately. |
@ShivaSunny9 I believe we've now fixed this issue with the release of |
@danielakhterov when I tried to integrate on react-native CLI I am getting errors. can you just help me with your package.json file and if possible can you share the source code of the project which you have implemented js-sdk. |
I'm having issues too. I'm using a pure React Native project (no expo). After adding to my package.json file these: expo-auth-session, expo-crypto, expo-random I was able to get the Mnemonic.generate() function working as expected. However, the following code doesn't work (passphrase is set to an empty string):
Gives me the following error: undefined is not an object (evaluating '_utf.default.encode') The output from the above is below.
To resolve the above issue, I applied the following patch (it seems to work):
Also just noticed the following when I start the server:
|
@ShivaSunny9 @robkainz As for the |
@danielakhterov I did try the master branch by including this in my package.json deps:
However, "yarn install" gave me this error:
I then tried:
but got this error when running:
Can you help me with the config to test out your master branch? If I do proceed with my patch, I get another error when Hedera tries to base64.decode() the response in NativeChannel.js. A response is retrieved, but decode() is called with undefined while passing responseData.split()[1] (I'm guessing split only returns one string, so undefined is there for index 1). I'm not sure my patch is the correct fix though but it was based on my quick research that there are differences with ESM scripts (which use import) vs CJS scripts (which use require) from the following article: https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1 I tried many different configurations, including what I gleaned from your package.json from your react native project. I even tried using the whole expo library but mine is still a bare React Native project and I really need to get this working (as I want to avoid using my native golang implementation if at all possible as maintenance of the bridge code will be costly and painful. |
@danielakhterov @ShivaSunny9 Hey guys, I'm going to first try and get Daniel's example to run, and then build up the configuration so it matches mine to make sure the example still runs (keeping it bare React Native with a few select expo libraries.) But I'm not able to get the react-native-example to run. It builds successfully and launches in the simulator, but the Hedera SDK calls do not complete successfully and I see the following in the simulator and the errors in the console. I tried the master branch (running it using "file:..") and also tried "2.0.17-beta.7". Both fail.
There appear to be two errors below (full console output follows):
|
@danielakhterov @robkainz I am trying to open the issue but I am not getting any option to open this issue again. |
@danielakhterov @robkainz Maybe we should open a new issue stating that we cannot get the react native example to run in the simulator. (In my case on IOS). |
when I am trying to use examples of Hashgraph JS SDK, in my react-native project. I am getting this error.
How do I solve this now?
The text was updated successfully, but these errors were encountered: