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

Vite error: Buffer is not defined #1847

Closed
blind675 opened this issue May 31, 2022 · 2 comments · Fixed by #1891
Closed

Vite error: Buffer is not defined #1847

blind675 opened this issue May 31, 2022 · 2 comments · Fixed by #1891

Comments

@blind675
Copy link

I get the following error:

Uncaught ReferenceError: Buffer is not defined
at node_modules/@react-pdf/unicode-properties/lib/unicode-properties.es.js (unicode-properties.es.js:268:31)
at __init (chunk-ACCAMVX6.js?v=3dcd2ad6:15:56)
at node_modules/@react-pdf/fontkit/lib/fontkit.browser.es.js

"vite": "2.9.9",
"@react-pdf/renderer": "2.1.2",

any idea why ?

@diegomura
Copy link
Owner

Yo need to polyfill Buffer if you're trying to run this lib on the web. Not sure how to do it with the stack your using or Vite, but it isn't an issue with this lib

@MarkForLoop
Copy link

MarkForLoop commented Jun 22, 2022

import { Buffer } from 'buffer'

globalThis.Buffer = Buffer

put that in ur index.jsx

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

Successfully merging a pull request may close this issue.

3 participants