Skip to content
← Back to Community
Using Browserify in a REPL
Profile icon

I have found a way to use Browserify in a REPL. You will need a Bash REPL for this.

First, install Browserify, along with your dependencies:

npm install browserify npm install uniq

Then, if you didn't already, run this to make package.json:

npm init -y

Then, add this entry under scripts in your package.json file:

"bundle": "browserify index.js > bundle.js"

It would look like this:

{ ... "scripts": { "bundle": "browserify index.js > bundle.js" } }

You can change the index.js to whatever file you want to browserify, as well as bundle.js.

Now make your index.js file if you haven't already, and this is what mine looks like:

var unique = require('uniq'); var data = [1, 2, 2, 3, 4, 5, 5, 5, 6]; console.log(unique(data));

Then, when you want, browserify it by using npm run bundle.

A new file will be created, and you can use it in your index.html file.

<script src="bundle.js"></script>

You can either make an HTML REPL and copy the code from your Bash REPL, or you can use Express to run it in the same REPL.

Profile icon
Profile icon