Can't get it to work - Buffer is not defined
See original GitHub issueOS: macOs 10.13.4
React-pdf version: “@react-pdf/renderer”: “^1.0.0-alpha.17”,
Description:
I am having trouble simply installing it into my app.
I run npm install @react-pdf/renderer --save
and I see the following issues in the tree…
├── UNMET PEER DEPENDENCY react@16.5.2
└── UNMET PEER DEPENDENCY react-dom@16.5.2
Then when I add the following to a file…
import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer';
I receive the following error…
Uncaught Reference Error: Buffer is not defined
Here is my package.json…
"dependencies": {
"@fortawesome/fontawesome": "^1.1.5",
"@fortawesome/fontawesome-free-solid": "^5.0.10",
"@fortawesome/react-fontawesome": "0.0.18",
"@react-pdf/renderer": "^1.0.0-alpha.17",
"antd": "^2.10.4",
"bcrypt": "^1.0.3",
"fabric": "^2.2.1",
"griddle-react": "^1.13.1",
"image-compressor.js": "^1.1.3",
"jquery": "^3.1.1",
"moment": "^2.22.2",
"prop-types": "^15.6.2",
"react": "^16.5.2",
"react-collapse": "^4.0.3",
"react-color": "^2.13.8",
"react-dom": "^16.5.2",
"react-icons": "^2.2.7",
"react-router": "^3.0.0",
"react-sortable-hoc": "^0.6.8",
"rgba-convert": "^0.3.0"
},
"engines": {
"node": "4.8.1"
},
"devDependencies": {
"babel-plugin-transform-class-properties": "^6.24.1",
"enzyme": "^2.7.1",
"expect": "^1.20.2"
},
"babel": {
"plugins": [
"transform-class-properties"
]
}
Where am I going wrong here? Do I need to be on a specific version of react? I also tried adding "buffer": "^5.1.0",
to my package.json file but the error still shows up.
Any help would be very much appreciated.
Thanks
How to replicate issue including code snippet (if applies):
You can make use of react-pdf REPL to share the snippet
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
@diegomura could you share what you used to fix this ? I’m facing the same issue and tried various things from the thread linked but still get the error.
npm install buffer
meteor npm install meteor-node-stubs
Meteor 1.8
Edit : fixed by
npm install meteor-node-stubs
(none of the above is needed).for Meteor 1.8.1 This solution worked for me
meteor npm uninstall --save meteor-node-stubs
meteor npm install --save meteor-node-stubs
Reference: https://mopethis.wordpress.com/2019/08/11/meteor-update-buffer-is-not-defined/