# node-define

> Makes AMD modules require’able in node by adding a global define function

Latest version **0.1.1** (published 2014-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-define
pnpm add node-define
yarn add node-define
bun add node-define
```

## 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.1.1 |
| Published | 2014-02-11 |
| First published | 2014-02-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | David Aurelio |
| Maintainers | davidaurelio |
| Keywords | node, amd, global, define, require, sync, synchronous |

## Links

- npm: https://www.npmjs.com/package/node-define
- Repository: https://github.com/davidaurelio/node-define
- Issues: https://github.com/davidaurelio/node-define/issues
- npm.io page: https://npm.io/package/node-define

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2014-02-11
- 0.1.0 — 2014-02-11

## README

node-define
===========

Makes AMD modules require’able in node by adding a global define function that delegates to RequireJS. The module configures RequireJS to use `process.cwd()` as `baseUrl` once and the module-local node `require` for every call to `define`.

Usage
-----

- Install with npm: `npm install node-define`
- Require the module: `require('node-define')`

**Note:** node-define deliberately does not expose `define.amd`. This way, modules in the UMD format will take the “node route” instead of using `define`. Named modules work better this way.

Further Configuration
---------------------

The module exposes RequireJS as `requirejs` property, and a `config` method that takes the same arguments as `requirejs.config`. Note that passing a `nodeRequire` option will be overwritten by node-define itself, as it always passes the module-local `require` to RequireJS.

Example: mocha tests
--------------------

For AMD-based projects with a mocha test suite, this module can help with executing the tests in node.js:

    mocha -r node-define

Letting mocha require the module will create a synchronous global `define` function that can load tests and code before mocha starts running, avoiding the problem that mocha does not pick up test suites when code is pulled in asynchronously.

For further configuration, a simple setup module can be created that pulls in node-require and provides further configuration. Simply pass that module to mocha with the `-r` switch.

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