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

"Module not found" in latest release (5.1.7) #46

Open
VasylBoyko opened this issue Mar 13, 2024 · 5 comments
Open

"Module not found" in latest release (5.1.7) #46

VasylBoyko opened this issue Mar 13, 2024 · 5 comments

Comments

@VasylBoyko
Copy link

Can't build the app anymore after your last release:

Module not found: Error: Can't resolve 'vm' in '~/app/node_modules/asn1.js/lib/asn1'
@ ./node_modules/asn1.js/lib/asn1.js 5:14-42
@ ./node_modules/parse-asn1/asn1.js 6:11-29
@ ./node_modules/parse-asn1/index.js 3:11-28
@ ./node_modules/browserify-sign/browser/sign.js 9:16-37
@ ./node_modules/browserify-sign/browser/index.js 7:11-28
@ ./node_modules/crypto-browserify/index.js 39:11-37

Looks like problem is here: f230870

@ljharb
Copy link
Member

ljharb commented Mar 13, 2024

vm is a node core module; presumably your bundler is failing to properly handle node core modules in its browser build?

@VasylBoyko
Copy link
Author

Yes, bundler is webpack 5, and it requires to add fallback: vm: require.resolve("vm-browserify").
Now i've added this fallback, and got new crash:
Uncaught TypeError: Cannot read properties of undefined (reading 'slice')
at ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js (_stream_writable.js:57:72)

@ljharb
Copy link
Member

ljharb commented Mar 13, 2024

Unfortunately webpack 5 decided to stop being a working node core module bundler by default. You'll have to manually configure a bunch of replacements. https://web3auth.io/docs/troubleshooting/webpack-issues#react-create-react-app has an example config that may prove useful.

Specifically, the readable-stream issue is that process.version isn't a string - but https://unpkg.com/readable-stream@2.3.8/lib/_stream_writable.js shows that if your bundler replaces process.browser with true, and then does dead code elimination, that entire line after && would be deleted and wouldn't run.

@VasylBoyko
Copy link
Author

VasylBoyko commented Mar 13, 2024

but guys, 5.1.7 causes problems in live projects, when 5.1.6 was perfectly worknig. Isn't it a reason to revert this commit?

@ljharb
Copy link
Member

ljharb commented Mar 13, 2024

@VasylBoyko again, unfortunately, sometimes bugfixes (which this one was) can still break people (obligatory xkcd 1172). i can't conceive of an application, including a RN one, where you wouldn't need to configure webpack and/or metro to properly and implicitly handle node globals and core modules, so I continue to be surprised people run into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants