Noder supports CommonJS Modules/1.0, as specified here. This basically allows a module to export its API through exports and to use the exported API from other modules through a synchronous require function. For information about how to write a module, you can refer to the documentation of node.js.
This page describes how to use Noder to load modules in a web browser.
Including noderJS in the page
First of all you need to load noderJS inside your page. The simplest way is to use a direct reference to
as shown below:
noder.dev.js is a development version of
noderJS. It is easy to use when debugging, as the code is not minified and the file includes error messages. However, it is not
recommended to be used in a production environment, as it is quite big so it is slow to download.
Alternatively, you can use one of the following files:
noder.dev.min.js: minified version of
noder.dev.js(with error messages)
noder.js: not minified, without error messages. In case an error occurs, the following extra files are automatically downloaded to display a readable error message:
noder.min.js: minified version of
noder.js(without error messages). This is the recommended version to use on a production environment, unless you want to create your own custom packaging of noderJS, as described here.
You can use noderJS directly from
noder-js.ariatemplates.com. Alternatively, if you want to work with noderJS offline,
or if you want to host it on your own server, you can get the full set of files either as a downloadable zip file or through the
To install noderJS through npm, you can use the following command:
npm install email@example.com
This will install client-side files in
node_modules/noder-js/dist/browser, for example:
Loading your first module
When the document is ready, noderJS reads all the script tags whose type attribute is
(this is configurable) and considers them as modules to be executed.
It is also possible to both load noderJS and a specific module with a single line:
A module loaded this way is considered the main module, available through
require.main (as it is done in Node.js), so
a module can check if it is the main module with:
module === require.main.
A configuration object can be specified inside the script tag to change the behavior of noderJS (check the configuration options for more details about available parameters):
You can find below a small hello world example (using Plunker) that shows how to load a module. You can click on the "Code" button to see the different files and on the "Preview" button to run the example. You can also click on the "Edit" button to open an online editor. This will allow you to change the files and try all the features of noderJS.