node-requirejs

Lets you use you requirejs configuration in Node

Showing:

Popularity

Downloads/wk

137

GitHub Stars

1

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

1

Size (min+gzip)

115.0KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

node-requirejs

Lets you use requirejs modules in Node

node-requirejs comes in hand when you have a requirejs based application and want to load your AMD defined modules in a Node environment. One possible use case for this is to unit test without any browser in the Node environment (with mocha, for example)

Getting started

npm install node-requirejs

Usage

You can instantiate and provide a configuration at the same time

var requirejs = require('requirejs').requirejs(yourRequireJSConfig);
var someModule = requirejs('some-module');

Or you can add an extra config on top of your 'normal' one

var requirejs = require('requirejs').requirejs(yourRequireJSConfig, someExtraConfig);
var someModule = requirejs('some-module');

N.B. The component has a default configuration (that you can of course override):

{
   baseUrl: '',
   nodeRequire: 'require'
}

Configuration

The module expose a config method that can be used to apply incremental configurations that will be painlessly merged into the existing configuration

E.g.

var requirejs = require('requirejs').requirejs(yourRequireJSConfig);
requirejs.config({ "baseUrl": "modules/level1" });
requirejs.config({ "paths": { "some-module": "level2/some-module" } });
var someModule = requirejs('some-module');

Test

npm test

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial