JS.InitModules
--------------

Installs Duktape module loading.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JavaScript](component_JavaScript.md) | [11.2](newinversion112.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JS.InitModules"; JSRef ) 

**MBS**( **"JS.InitModules";** /\* Installs Duktape module loading. \*/  
**$JSRef**) /\* The JavaScript reference number.e.g. $js \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| JSRef | The JavaScript reference number. | $js |

### Result

Returns OK or error.

### Description

Installs Duktape module loading.  
Only calls JS.InitModules once on a new instance of the JavaScript engine.  
Define your own Duktape.modSearch() to provide environment specific module lookups.  
After these steps, require() will be registered to the global object and the module system is ready to use.  
### Examples

Create JavaScript environment and enable modules:

 Set Variable \[ $$JS ; Value: MBS ("[JS.New](JSNew.md)") \]   
\# enables require() to use Duktape.modSearch   
Set Variable \[ $r ; Value: MBS ( "JS.InitModules"; $$js ) \]  
### See also

- [JS.New](JSNew.md)

### Release notes

- **Version 11.2**
    - Added [JS.InitModules](https://www.mbsplugins.eu/JSInitModules.shtml) function.

### Example Databases

- [JavaScript/JavaScript](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JavaScript/JavaScript.shtml#10ScriptAnchor_)

### Blog Entries

- [New in MBS FileMaker Plugin 11.2](https://www.mbsplugins.de/archive/2021-05-26/New_in_MBS_FileMaker_Plugin_11/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 11.2](https://www.mbsplugins.de/archive/2021-05-18/Neues_MBS_FileMaker_Plugin_112/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.2 - More than 6500 Functions In One Plugin](https://www.mbsplugins.de/archive/2021-05-18/MBS_FileMaker_Plugin_112_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.2pr1](https://www.mbsplugins.de/archive/2021-04-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 24th March 2021 , last changed 13th June 2021

  
[JS.GetGlobalPropertyValue](JSGetGlobalPropertyValue.md) - [JS.List](JSList.md)

[HTML Version](JSInitModules.shtml)