-
Notifications
You must be signed in to change notification settings - Fork 237
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
Buffer is not defined #757
Comments
The issue is that Buffer is automatically polyfilled in Browserify, but Vite doesn't use To get it to work, I had to do:
main.ts (entrypoint)
vite.config.ts
Altering either one of |
following on from @rhythnic's comment above. i had to do the following to get it working in a standard create-react-app project then add in index.js |
See related earlier issue and PR: #747 and see also https://stackoverflow.com/q/70296914/470749 |
This also happens if you try to bundle your app with esbuild and
The reason why it tries to bundle Maybe it would be an idea to switch to another sha256 dependency? It seems to be unmaintained and the respective issue on their side is open for a long time: emn178/js-sha256#26 |
- no more unsafe eval - fixes esbuild and vitejs toolings resolves near#757
Just a temp solution install buffer
In the index.ts file, add the following code.
|
This is not work production build. |
I found a fix that fixed the Buffer error for me.
// vite.config.js
Hope this helps |
Just resolved this error in a CRA. Follow this link: resolve buffer error in create-react-app |
@gtsonevv we should check if this issue is still relevant now that we've replace js-sha256 |
Describe the bug i use vite to hold near-api-js
Expected behavior no error
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context start project with vite
The text was updated successfully, but these errors were encountered: