# node-amd-require

> Augment node's require() to globally handle AMD modules

Latest version **0.2.2** (published 2013-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-amd-require
pnpm add node-amd-require
yarn add node-amd-require
bun add node-amd-require
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2013-08-17 |
| First published | 2013-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Zach Shipley |
| Maintainers | zship |
| Keywords | amd |

## Links

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

## Dependencies (2)

- [libamd](https://npm.io/package/libamd.md) 1.x
- [amdefine](https://npm.io/package/amdefine.md) 0.x

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.2.2 (latest) — 2013-08-17
- 0.2.1 — 2013-08-12
- 0.2.0 — 2013-08-11
- 0.1.5 — 2013-08-10
- 0.1.4 — 2013-08-10
- 0.1.3 — 2013-08-08
- 0.1.2 — 2013-08-08
- 0.1.1 — 2013-08-03
- 0.1.0 — 2013-08-03

## README

node-amd-require
================

node-amd-require is a small script which adds AMD-style path resolution and
`define` support to node's `require()` function. It can be used as an AMD
loader or to add [path
configuration](http://requirejs.org/docs/api.html#config-paths) support to
CommonJS modules.


Installation
------------

Using npm:

```
npm install node-amd-require
```


Usage
-----

`require` node-amd-require in your project's main entry point and call with
your desired [AMD-style
configuration](http://requirejs.org/docs/api.html#config). Supports `baseUrl`,
`paths`, and `packages`. Also supports the
[mainConfigFile](http://requirejs.org/docs/optimization.html#mainConfigFile)
property recursively.

```js
/* [your index.js file or similar] */

require('node-amd-require')({
	//configuration from https://github.com/zship/deferreds.js
	baseUrl: '.',
	paths: {
		"deferreds": "src",
		"mout": "lib/mout",
	}
});

var path = require('path');
var fs = require('fs');
//...
```

Or pass a path to a .json file containing your configuration:

```js
/* [your index.js file or similar] */

require('node-amd-require')('/path/to/config.json');

var path = require('path');
var fs = require('fs');
//...
```


Features
--------

* Adds AMD configuration-based path resolution to `require` for AMD and/or
  CommonJS modules
* Adds `define` and RequireJS loader plugin support to `require` via
  [amdefine](https://github.com/jrburke/amdefine) and the
  [require.extensions](http://nodejs.org/api/globals.html#globals_require_extensions)
  mechanism.
* Unlike [requirejs in node](https://github.com/jrburke/r.js/),
  node-amd-require can support downstream scripts which directly call `require`
  on your possibly-AMD-format scripts (such as [grunt](http://gruntjs.com/) and
  [mocha](http://visionmedia.github.io/mocha/)). More on that is in [this
  requirejs
  issue](https://github.com/jrburke/requirejs/issues/450#issuecomment-8465160).
* Does not clobber external libraries (symlinks too)
  * That is, `define` (AMD module support) is only added when `require` is
	called **into** your project (any file calls
	`require("/file/inside/your/project.js"))


License
-------

Released under the [MIT
License](http://www.opensource.org/licenses/mit-license.php).

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