Skip to content

Node Modules

Jason edited this page Jul 1, 2014 · 3 revisions

Lazo uses RequireJS (AMD) for loading application modules to help normalize the loading of modules between the client and the server. Node uses require, which follows the CommonJS format. RequireJS will delegate to Node's require in the event that it cannot find a module. Node require will attempt to resolve modules from the script that started the process by traversing up the directory tree. In this case the script that started the process is Lazo which resides where the Lazo node module was installed.

Resolving Node Modules

If a server module fails to load the Lazo loader will make a few different attempts to load the module using Node require. For instance, if you have a node module in app/server/node_modules/some_module the loader will expand the path from app/server/some_module to ABSOLUTE_ PATH/app/server/some_module. If that fails it will try ABSOLUTE_PATH/app/server/node_modules/some_module.

If a node module is global and $NODE_PATH is set then it can be loaded by id. Node core modules can also be loaded by id.