Skip to content
javascript module management. brings node's require statement and npm to the browser
JavaScript HTML
Latest commit 7d13921 Jul 14, 2015 @marcuswestin v2.4.20
Failed to load latest commit information.
bin Add --root and --usePagePort flags to require command May 6, 2015
example Remove use of sys module Jun 24, 2012
lib No longer toLowerCase - doesn't work on linux Jul 14, 2015
.gitignore Remove node_modules directory - list dependencies in package.json ins… Jun 30, 2011
Changelog v0.5.0 Mar 30, 2013
LICENSE There is no conceptual stuff in here from anymore May 16, 2011 simplify require server options Mar 30, 2013
package.json v2.4.20 Jul 14, 2015
server.js fix compile command Oct 21, 2014

require brings require to the browser

Node's require() is the de facto javascript dependency statement.

npm is the de facto javascript module manager.

require brings both of them to the browser.


"Just give me some code that runs"

mkdir app; cd app
echo '{ "name":"app" }' > package.json
sudo npm install require
sudo npm install raphael
curl -O
curl -O
node little_server.js

Now go to http://localhost:8080


sudo npm install -g require


Start dev server

require serve ./example --port 1234 --host localhost

In your HTML:

<script src="//localhost:1234/require/client"></script>

This is like calling require('client') from inside ./example. Read more on node's require path resolution


(You'll want to do this before you deploy to production)

require compile ./example/client.js > client.min.js

Use programmatically

In node:


or mount it on an http server you're already running

var server = http.createServer(function(req, res) { })
server.listen(8080, 'localhost')

or, as connect middleware

    connect.static(__dirname + '/example'),

Compile programmatically:

var compiler = require('require/compiler')

The compiler supports all the options of, e.g.

compiler.compile('./example/client.js', { beautify:true, ascii_only:true })
Something went wrong with that request. Please try again.