i was getting the same error and this is how i solved the problem. but i have no clue as to why.
firs:
npm install --save buffer
(i don't know what it does, but it worked.) and then;
import { buffer } from "buffer";
buffer.from("anything", "base64");
window.buffer = window.buffer || require("buffer").buffer;
i got this buffer error when i tried to upload object (doc/pdf/image) etc from react to aws s3 bucket. then after referring multiple website i got the solution below.
find this sample react code to understand.
import logo from './logo.svg';
import './app.css';
import s3fileupload from 'react-s3';
window.buffer = window.buffer || require("buffer").buffer;
function app() {
const onfilechange = (file)=>{
const config = {
bucketname: '190031527bucket01',
dirname: 'photos', /* optional */
region: 'us-east-1',
accesskeyid: 'akiaqefwnsiyun6cmdg4',
secretaccesskey: 'h322hndkykdlygvn6lloxswzmw9ht9aqgrpnneut',
s3fileupload.uploadfile(file, config)
.then((data)=>{
console.log(data.location);
}).catch((err)=>{
alert(err);
return (
<div classname="app">
<h1>hello react</h1>
<input type="file" onchange={(e)=>onfilechange(e.target.files[0])} />
export default app;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
window.buffer = window.buffer || require("buffer").buffer;
add this statement after all the import statements to get rid of "buffer is not defined"
Uncaught ReferenceError: Buffer is not defined in React
React Uncaught ReferenceError: Buffer is not defined
Uncaught ReferenceError: React is not defined
React Uncaught ReferenceError: process is not defined
Uncaught ReferenceError: React is not defined
Uncaught ReferenceError: regeneratorRuntime is not defined in React
React JS Uncaught Reference Error: function not defined
React - Uncaught ReferenceError: require is not defined
Uncaught ReferenceError: regeneratorRuntime is not defined in react 17, webpack 5 while making api calls through actions
Error: Uncaught ReferenceError: React is not defined
gulp + browserify + reactjs, Uncaught ReferenceError: React is not defined
Uncaught ReferenceError: Link is not defined React
ReactJS Uncaught ReferenceError function is not defined
keccak.js Uncaught ReferenceError: Buffer is not defined
Base45 - Uncaught ReferenceError: Buffer is not defined (React JS)
Uncaught ReferenceError: controller is not defined in react js
React fixed-data-table: Uncaught ReferenceError: Table is not defined
Intégrating React into Symfony (Webpack Encore) : ReferenceError : React is not defined
React js with jsx: Uncaught ReferenceError: require is not defined
Uncaught (in promise) ReferenceError: data is not defined in react component
React uncaught reference error: exports is not defined
Plunker Uncaught ReferenceError: React is not defined
Uncaught ReferenceError: require is not defined on React
Meteor React Uncaught ReferenceError: Peer is not defined
Why is this exception being thrown? Uncaught ReferenceError: React is not defined
React - Rails Uncaught TypeError 'map' of data not defined
Error on using exports in a React application - Uncaught ReferenceError: exports is not defined
React - Uncaught ReferenceError: add is not defined
Uncaught ReferenceError: process is not defined error when converting react (TS) app to PWA with webpack and babel config
React Sasy DatePicker throwing this error : Uncaught ReferenceError: process is not defined
More Query from same tag
How to call onEnter function on Route in React Router Multiple times
What is the best practice to "re-render" a Component in React?
Do props from state overwrite props from parent, using React-Redux?
react-indiana-drag-scroll the shadow of the last item not shown
props.history not found when using withRouter
Change the height and width on a google map in React js
How to access array in array from react component?
How to upgrade from react-router to react-router-dom?
What's the risk of modifying the state without setState?
Check screen size change for a specific width
why do I have "Warning: undefined(...): Cannot update during an existing state transition..." error?
React.JS: Nested Filter/Map Arrays
"Unhandled Rejection (TypeError): snapshot.data is not a function" when calling Firestore in useEffect
React js onClick function in a map function is not recognized
Updating Parent Component state from multiple child components' componentDidMount() synchronously
How to send a token from react to my server?
Loadable Components SSR - chunkNames in Server Stats file different from Client stats file
Class is not applied to Material UI button component
How to write dynamic routing for SEO friendly URL's in React JS
how to download an excel file in react from NodeJS
Redux-Form, how to use a Ref with a renderField?
Could not find "store" in the context of "Connect
How to validate one field against another with Yup?
Add the classes after 2 loops on react using map
Updating Parent Component State from Child Component with UseState React Hook
React Redux - Wait until data is loaded
How to call onFinish method of form in child component from parent in ant design framework
How to pass JSON as a prop?
Starting a react app in HTTPS instead of HTTP
using search bar css in react