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

webpack 5: ReferenceError: Buffer is not defined #216

Closed
alerios opened this issue Jan 27, 2022 · 3 comments · Fixed by #217
Closed

webpack 5: ReferenceError: Buffer is not defined #216

alerios opened this issue Jan 27, 2022 · 3 comments · Fixed by #217
Labels
bug Something isn't working released

Comments

@alerios
Copy link

alerios commented Jan 27, 2022

Prerequisites

Current Behavior

When using did-jwt with webpack 5, the following error shows up: "ReferenceError: Buffer is not defined", since Buffer is not included in the browser.

Failure Information

There are several references to the use of "Buffer.from" in the did-jwt code: https://github.com/decentralized-identity/did-jwt/search?q=%22Buffer.from%22

Alternatives you considered

Based on what I could find, these could be replaced to use "u8a.fromString" instead for better compatibility.

In the meantime I applied a polyfill using this guide, which cleared the issue: https://viglucci.io/how-to-polyfill-buffer-with-webpack-5


Don't paste private keys anywhere public!

@alerios alerios added the bug Something isn't working label Jan 27, 2022
@mirceanis
Copy link
Member

Thanks for reporting this!
Since you already suggested a fix and a workaround, do you want to create a PR with the fix?

@ukstv
Copy link
Contributor

ukstv commented Jan 27, 2022

There is now a PR to fix this: #217

mirceanis pushed a commit that referenced this issue Jan 27, 2022
uport-automation-bot pushed a commit that referenced this issue Jan 27, 2022
## [5.12.4](5.12.3...5.12.4) (2022-01-27)

### Bug Fixes

* use uint8arrays instead of Buffer ([#217](#217)) ([d9de4fc](d9de4fc)), closes [#216](#216)
@uport-automation-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 5.12.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants