- require the npm package the you need
const Buffer = require('buffer').Buffer
- Append the variable to the window object
global.window.Buffer = Buffer
- Install browserify as devDep
yarn add browserify -D
- Compile your main.js file using browserify
browserify main.js -o output.js
- use your output.js on your html
<script src="output.js" ></script>