# require

> javascript module management! brings node's require statement to the browser

Latest version **2.4.20** (published 2015-07-14) · 0 weekly downloads

## Install

```sh
npm install require
pnpm add require
yarn add require
bun add require
```

Provides the command `require`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.20 |
| Published | 2015-07-14 |
| First published | 2011-04-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 58 |
| Author | Marcus Westin |
| Maintainers | marcuswestin |

## Links

- npm: https://www.npmjs.com/package/require
- Repository: https://github.com/marcuswestin/require
- Issues: https://github.com/marcuswestin/require/issues
- npm.io page: https://npm.io/package/require

## Dependencies (2)

- [std](https://npm.io/package/std.md) 0.1.40
- [uglify-js](https://npm.io/package/uglify-js.md) 2.3.0

## Recent versions

- 2.4.20 (latest) — 2015-07-14
- 2.4.19 — 2015-07-10
- 2.4.18 — 2015-05-07
- 2.4.17 — 2014-10-21
- 2.4.16 — 2014-10-21
- 0.5.1 — 2014-10-21
- 0.5.0 — 2013-03-31
- 0.4.9 — 2012-04-12
- 0.4.8 — 2012-03-04
- 0.4.6 — 2011-08-10
- 0.4.5 — 2011-08-07
- 0.4.4 — 2011-05-17
- 0.4.2 — 2011-05-02
- 0.4.0 — 2011-04-22
- 0.3.2 — 2011-04-22
- … 1 more at https://npm.io/package/require/versions

## README

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.

tl;dr
=====
"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 https://raw.github.com/gist/975866/little_server.js
	curl -O https://raw.github.com/gist/975868/little_client.js
	node little_server.js

Now go to http://localhost:8080

Install
=======

	sudo npm install -g require

Run
===
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](http://nodejs.org/api/modules.html)

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

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

Use programmatically
====================
In node:

	require('require/server').listen(1234)

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

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

or, as connect middleware

	connect.createServer(
		connect.static(__dirname + '/example'),
		require('require/server').connect()
	)

Compile programmatically:

	var compiler = require('require/compiler')
	console.log(compiler.compile('./example/client.js'))
	console.log(compiler.compileCode('require("./example/client")'))

The compiler supports all the options of https://github.com/mishoo/UglifyJS, e.g.

	compiler.compile('./example/client.js', { beautify:true, ascii_only:true })

---
_Source: https://npm.io/package/require · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
