Buffer not found in Node.JS browser code
<p>I want to use a node.js function on the browser with <code>browserify</code>. In my code, there is a line as follows:</p>

<pre><code>var x = new Buffer('abc..', 'hex')
</code></pre>

<p>However, this causes an error <code>ReferenceError: Buffer is not defined</code>. I tried to install <code>[buffer-browserify][1]</code> and include it like this:</p>

<pre><code>var Buffer = require('buffer');
</code></pre>

<p>but now I get the error <code>Error: Cannot find module 'buffer'</code>..</p>

<p>so -how- can I use the <code>Buffer</code> class in browser javascript?</p>

<p>Thanks for any help,</p>

<h2>Update:</h2>

<p>In order to build it with <code>browserify</code>, I created an <code>input.js</code> file as follows:</p>

<pre><code>var Buffer = require('buffer');
console.log(Buffer);
</code></pre>

<p>and I tried to build it with <code>browserify input.js -o output.js</code> and I included <code>output.js</code> in my browser code, it prints the <code>Buffer</code> variable. However, I still get the same error (<code>ReferenceError: Buffer is not defined</code>) when I try to use it.</p>