Requiring a Node.js module ​
SyncJS supports the require keyword, similar (but not identical) to Node.js. You must require a module before using any of its exported functions—attempting to use a module's functions without requiring it first will result in a runtime error.
For example, this script will fail at runtime:
ts
// Will **CRASH** because the underscore module hasn't been required
if (_.contains([1, 2, 3], 3)) {
Log('Yay!');
}But this script will run correctly:
ts
// Require the minified Underscore.js module
var _ = require("underscore-min");
// Now you can use the "contains" function from the required module
if (_.contains([1, 2, 3], 3)) {
Log('Yay!');
}To require modules, they must be installed in the modules subdirectory of Syncplify Server!'s configuration folder. Typically, this folder is located at:
- Windows:
C:\ProgramData\Syncplify\Server\modules - Linux/Unix:
/etc/Syncplify/Server/data/modules
WARNING
SyncJS does not use or integrate Node.js itself. While many Node.js modules are compatible, not all will work in the SyncJS runtime environment.
