npm install -g browserify
Browsers don't have the require method defined, but Node.js does. With Browserify you can write code that uses require in the same way that you would use it in Node.
Here is a tutorial on how to use Browserify on the command line to bundle up a simple file called main.js along with all of its dependencies:
var unique = require('uniq'); var data = [1, 2, 2, 3, 4, 5, 5, 5, 6]; console.log(unique(data));
npm install uniq
browserify main.js -o bundle.js
Browserify is elegant and fast. It makes frontend development fun again! That's why we used it to build Yahoo's new HTML5 video player. - feross, developer on the Video team at Yahoo.
Browserify does exactly what it says it does and it does it well. I'm glad it exists. - zpao, developer on the React team at Facebook.
Browserify radically sped up builds, simplified builds and encouraged modularity. - terinjokes, developer at CloudFlare.