Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.3K
Vistas
How to use node Buffer module in a client side browser - detailed explanation required please

First things first. I know that there are other questions that are similar to this e.g. use NodeJs Buffer class from client side or How can I use node.js buffer library in client side javascript

However, I don't understand how to make use of the reference to use browserify though it is given approval.

Here is my Node code:

import { Buffer } from 'buffer/';

I know this is the ES6 equivalent of require.

I would like a javaScript file implementation of this module so that I can simply use the standard html file reference:

<script src=./js/buffer.js></script>

And then use it as in for example

return new Buffer(temp).toString('utf-8');

This simply falls over with the

Uncaught ReferenceError: Buffer is not defined 

no matter how I create the buffer.js file.

So using the browserify idea I've tried using the standalone script (from the https://www.npmjs.com/package/buffer as https://bundle.run/buffer@6.0.3 )

I've created a test.js file and put

var Buffer = require('buffer/').Buffer 

in it and then run browserify on it as

browserify test.js -o buffer.js

and many other variations. I'm not getting anywhere. I know I must be doing something silly that reflects my ignorance. Maybe you can help educate me please.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

These instructions worked for me. Cheers!

Here are the instructions you can look at the web section. https://github.com/feross/buffer

Here is what the instructions state about using it in the browser without browserify. So from what you tried

 browserify test.js -o buffer.js

I would just use the version directly that does not require browserify

To use this module directly (without browserify), install it:

npm install buffer

To depend on this module explicitly (without browserify), require it like this:

var Buffer = require('buffer/').Buffer // note: the trailing slash is important!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda