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

Unable to resolve "@adraffy/ens-normalize/xnf" in react native #3724

Closed
HEGADE opened this issue Feb 3, 2023 · 32 comments
Closed

Unable to resolve "@adraffy/ens-normalize/xnf" in react native #3724

HEGADE opened this issue Feb 3, 2023 · 32 comments
Labels
fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6

Comments

@HEGADE
Copy link

HEGADE commented Feb 3, 2023

i have installed the ethers package , but when I'm trying to use it ,it is giving "Unable to resolve "@adraffy/ens-normalize/xnf" from "node_modules\ethers\lib.commonjs\hash\namehash.js" error .

ethers version- "^6.0.0"

@ricmoo
Copy link
Member

ricmoo commented Feb 3, 2023

Does your version of RN support the exports feature of package.json? Is there are option to specify node16 as the module resolution?

@HEGADE
Copy link
Author

HEGADE commented Feb 3, 2023

Does your version of RN support the exports feature of package.json? Is there are option to specify node16 as the module resolution?
yes supports export, and I have downgraded the ethers to "^5.6.6", and it's working fine

@ricmoo
Copy link
Member

ricmoo commented Feb 3, 2023

The v5 branch of ethers uses a vended version of the ens-normalize. Which is out-dated, so moving to the latest package is to help ensure names are resolved correctly, and offload updates to the author of the standard.

Can you verify the node_modules/@adraffy/ens-normalize/package.json contains the proper ./xnf entry in its exports and that the version is 1.8.9?

@HEGADE
Copy link
Author

HEGADE commented Feb 3, 2023

okay tq, let me check

@HEGADE
Copy link
Author

HEGADE commented Feb 3, 2023

The v5 branch of ethers uses a vended version of the ens-normalize. Which is out-dated, so moving to the latest package is to help ensure names are resolved correctly, and offload updates to the author of the standard.

Can you verify the node_modules/@adraffy/ens-normalize/package.json contains the proper ./xnf entry in its exports and that the version is 1.8.9?

yes I have verified it , version is 1.8.9

@ricmoo
Copy link
Member

ricmoo commented Feb 3, 2023

Ok. One more ask. Can you remove the /xnf suffix in the import from the node_modules/ethers/lib.commonjs/hash/namehash.js? And see if that fixes it?

@HEGADE
Copy link
Author

HEGADE commented Feb 3, 2023

okay sure

@ricmoo
Copy link
Member

ricmoo commented Feb 4, 2023

@HEGADE did that work?

@grabbou
Copy link

grabbou commented Feb 5, 2023

Yes, that did work. Unfortunately, another issue is:

The package at "node_modules/ethers/lib.commonjs/providers/provider-ipcsocket.js" attempted to import the Node standard library module "net"

@ricmoo
Copy link
Member

ricmoo commented Feb 5, 2023

It seems like your bundler is ignoring the browser field in the package.json. You probably meet to enable it in your bundler config.

@NTBooks
Copy link

NTBooks commented Feb 6, 2023

I had this same issue and could not resolve it. Removing /xnf made my program compile again but modifying library files is no solution (and it didn't work anyway)
I downgraded to 5.7.2 and it works again.

@ricmoo
Copy link
Member

ricmoo commented Feb 6, 2023

I’ll be using the non-xnf in the next patch release, and try using the browser field to adjust the xnf.

I’m also considering a RN-specific package, which wraps all the necessary native libraries, and shims. If anyone would like to help out with that, that is more familiar with RN, that would be appreciated. :)

@HEGADE
Copy link
Author

HEGADE commented Feb 6, 2023

@HEGADE did that work?

sorry ,didn't work

@bytesbay
Copy link

@ricmoo
Have a good day. Seems like I have the same error for jest while testing my app (node 14 and testEnvironment: "node")
Can you help please?

@grabbou
Copy link

grabbou commented Feb 13, 2023

@ricmoo, I am happy to help and got some RN experience. What's the best way to connect? Email/Discord?

@ricmoo ricmoo added on-deck This Enhancement or Bug is currently being worked on. v6 Issues regarding v6 labels Feb 13, 2023
@ricmoo
Copy link
Member

ricmoo commented Feb 16, 2023

This should be resolved in v6.0.4, try it out and let me know if there are any problems.

The expansion was moved from using the ens-normalize exports to the ethers pkg.browser.

Thanks! :)

@ricmoo ricmoo added the fixed/complete This Bug is fixed or Enhancement is complete and published. label Feb 16, 2023
@ricmoo ricmoo closed this as completed Feb 18, 2023
@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Feb 23, 2023
@dtourassis
Copy link

dtourassis commented Feb 23, 2023

@ricmoo I'm facing the same error with @grabbou when I try to use v6 with RN 0.68 (Expo 45 / Metro). Any ideas on how to enable Metro to take into account the browser field from package.json?

The package at "node_modules/ethers/lib.commonjs/providers/provider-ipcsocket.js" attempted to import the Node standard library module "net"

@ricmoo
Copy link
Member

ricmoo commented Feb 23, 2023

@dtourassis are you using the latest version? It no longer uses the xnf exports field.

@dtourassis
Copy link

@ricmoo Yes, I'm running ethers version 6.0.8. Just to clarify, I don't see the first error @grabbou was having with xnf, only the second one related to the net package.

@ricmoo
Copy link
Member

ricmoo commented Feb 23, 2023

I’m working on a RN-specific build, that takes all the shins into account. I’ll keep this issue updated with my status.

There should be some way to configure your bundler though. I think, there should be some sort of webpack config.

@dtourassis
Copy link

Thank you! Any ETA on the RN build?
Btw, It bundles up fine in the browser using Webpack but Metro is the default bundler for mobile. I'll keep digging in the Metro docs for now.

@ricmoo
Copy link
Member

ricmoo commented Feb 23, 2023

It likely won’t be anytime in the next few weeks. There is still a lot of other things to get polished first. And I have to learn a lot more about RN first.

@bciach
Copy link

bciach commented Mar 9, 2023

@dtourassis any luck?

@manan19
Copy link

manan19 commented Apr 14, 2023

Running into the same issue as @dtourassis. On Expo SDK 48. ethers version is ~6.2.1.

The package at "node_modules/ethers/lib.commonjs/providers/provider-ipcsocket.js" attempted to import the Node standard library module "net".

@ricmoo Any updates? Could we re-open this issue while it's still being looked at?

@ricmoo
Copy link
Member

ricmoo commented Apr 14, 2023

@manan19 have you updated to 6.3?

@manan19
Copy link

manan19 commented Apr 14, 2023

@ricmoo Yup, same issue.

How do I import the browser version only in my package.json?

@ricmoo
Copy link
Member

ricmoo commented Apr 15, 2023

The xnf version is no longer used anywhere in ethers, so it shouldn’t give the error in the OP. Are you sure it is the same error?

@ricmoo ricmoo reopened this Apr 15, 2023
@ricmoo ricmoo closed this as completed Apr 15, 2023
@dtourassis
Copy link

dtourassis commented Apr 16, 2023

@ricmoo If I understood correctly @manan19 is having a problem related to the "net" module from Node, not xnf.

@bciach Not really, ended up using a patched version of v5.

@manan19
Copy link

manan19 commented Apr 17, 2023

@ricmoo If I understood correctly @manan19 is having a problem related to the "net" module from Node, not xnf.

That's correct. Although it seems fair to close this issue and open a new one for what I reported. It stems from the problem that the Metro bundler (using Expo Go) doesn't choose the *-browser.js files.

@clayrisser
Copy link

I'm facing the same issue. Not sure why this was closed without filing a new issue as this library does not work with expo because it's not loading the browser files.

@clayrisser
Copy link

Android Bundling failed 61701ms
The package at "node_modules/ethers/lib.commonjs/providers/provider-ipcsocket.js" attempted to import the Node standard library module "net".
It failed because the native React runtime does not include the Node standard library.

@clayrisser
Copy link

Turns out it works with ethers 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

9 participants