Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

659
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda