---
sourceDocument: Brazil Build or modify applications
sourceDocumentLink: https://www.servicenow.com/docs/r/application-development

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# JavaScript modules and third-party libraries

# JavaScript modules and third-party libraries {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of JavaScript modules and third-party libraries

JavaScript modules in ServiceNow allow you to organize related code and reuse it within applications.
Modules are JavaScript files stored in theEcmaScript Module \[sysmodule\]table after application installation.
You can create modules using the ServiceNow IDE or SDK and also use TypeScript compiled to JavaScript.
To reuse code, export it from modules and import or require it elsewhere in your application code.
Third-party libraries managed through Node Package Manager (npm) must be added as dependencies to your application to be used.
Show full answer Show less  
Note that global Glide Server APIs are accessible in modules via imports from the `@servicenow/glide` package.

## Limitations

* Modules work only within their own application scope and cannot be shared across scopes.
* Only a subset of ECMAScript features are supported; Node.js APIs and certain global web API variables are not supported.
* CommonJS modules are supported only if they define exports; subpath imports aren't supported with CommonJS.
* `import` and `export` statements are supported only within modules; use `require` in scripts like business rules or script includes.
* JavaScript modules can be modified only via ServiceNow IDE or Visual Studio Code with the SDK.
* Third-party libraries relying on unsupported features cannot be used.

## Exporting and Importing Modules

Use named or default `export` statements to identify reusable code in a module. Named exports can include variables, constants, functions, or classes; default exports are restricted to functions or classes.

Import code in other modules using `import` statements, or in server-side scripts using `require`. When importing TypeScript files, include the `.ts` extension.

You can simplify imports by defining subpath aliases in your application's `package.json` file, allowing shorter import statements for dependencies or internal module paths.

## Adding Third-party Libraries

Declare third-party libraries as dependencies in your application's `package.json` file with their package names and versions. This enables use of their exported module code within your application.

## Importing Server APIs and Script Includes

Server Glide APIs can be imported into modules from the `@servicenow/glide` package or specific namespaces. For example, you can import `gs` (GlideSystem), `GlideRecord`, or REST API classes.

To use server APIs in third-party modules, add those modules as trusted in your application's `now.config.json` file.

Script includes can also be imported from the global or application scope via the `@servicenow/glide` package.

## Practical Considerations for ServiceNow Customers

* Use JavaScript modules to improve code organization and reuse within your scoped applications.
* Manage third-party dependencies explicitly in `package.json` to ensure proper packaging and availability.
* Leverage subpath imports to simplify and standardize module imports across your application.
* Import server APIs and script includes correctly to integrate native ServiceNow functionality within modules.
* Be aware of limitations such as scope restrictions and unsupported Node.js APIs when designing your application architecture.  
Optimize your code base using JavaScript modules to group related code or add third-party libraries and reuse their code within applications.

## Overview of using JavaScript modules {#javascript-modules-third-party-libraries__section_h3h_qzn_jzb}

A module is a JavaScript file that contains related code that's shared and reused within applications on an instance. You can add JavaScript modules and third-party libraries in
applications that are created or converted with the ServiceNow IDE or ServiceNow SDK. You can also use TypeScript to create modules and compile them to JavaScript before building your application. After installing an application on an instance, JavaScript modules are stored in the
EcmaScript Module \[sys_module\] table.

In a module, you identify code for reuse with export statements. Then, use import or require statements to reuse the code elsewhere in your applications. You must add
third-party Node Package Manager (npm) libraries to applications as dependencies to use their module code. For general information about the syntax used to create JavaScript modules, see the [JavaScript modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) page on the MDN Web Docs website.  
Note:  
To use global Glide Server APIs in modules, they must be imported from the `@servicenow/glide` package. For more information, see [Importing server APIs](https://www.servicenow.com/docs/RmSk495yFVBcVPtAM8XPFA#javascript-modules-third-party-libraries__section_pn3_lsk_cfc).

## Limitations {#javascript-modules-third-party-libraries__section_rps_4fw_jzb}

* Application customizations aren't supported.
* Modules can be used only within the application scope in which they're added. They can't be used across application scopes.
* A subset of ECMAScript features are supported in modules in accordance with the [JavaScript engine feature support](https://www.servicenow.com/docs/access?context=javascript-engine-feature-support&version=brazil&pubname=brazil-api-reference&ft:locale=en-US).
* Node.js APIs aren't supported in modules. The ServiceNow SDK build process polyfills any Node.js built-in modules while packaging modules, otherwise modules are resolved from the node_modules directory.
* Global variables related to web APIs aren't supported.
* CommonJS modules from third-party libraries aren't supported unless they define exports. Subpath imports aren't supported with CommonJS modules. ECMAScript modules from third-party libraries are supported.
* import and export statements are only supported in modules. To import module code in scripts, such as business rules or script includes, use require statements.
* JavaScript modules \[sys_module\] can be modified only in the ServiceNow IDE or in Visual Studio Code with the ServiceNow SDK.
{#javascript-modules-third-party-libraries__ul_fb4_w3t_pzb}  
Important:  
You can't use third-party libraries that rely on unsupported functionality, such as unsupported APIs or ECMAScript features. For more information, see [Third-party library support in Brazil](https://www.servicenow.com/docs/G~g4b63YEHBs1XFrX85VaA "Review which common third-party libraries are supported, partially supported, or unsupported by the ServiceNow IDE and ServiceNow SDK.").

## Exporting modules {#javascript-modules-third-party-libraries__section_y3l_jmy_mzb}

In a module, identify code for reuse with export statements. You can use named exports or default exports. Named exports can be for variables, constants, functions, or classes whereas default exports can be for functions or classes only. The following example is one way of adding a named export for multiple features (a function and a variable) in a module:

    export { myFunction, myVariable };

## Importing modules {#javascript-modules-third-party-libraries__section_clq_fmf_nzb}

To import the module code you want to reuse, use import statements in other modules or require statements in server-side scripts.  
The following example is one way that you could import an exported feature in a module:

    import { feature } from 'path/to/module';

The following example is one way that you could import an exported feature in a script:

    const { feature } = require('path/to/module');

Note:  
To import code from one TypeScript file to another TypeScript file, you must include the `.ts` file extension. For example, `import { feature } from
'./module.ts'`.  
To use shorthand to import module code, you can use subpaths in the imports field of the application's package.json file. For example:

    {
    	"name": "math",
    	"version": "1.0.0",
    	"exports": {
    		"./functions/*.js": "./src/functions/*.js",
    		"./functions/private-functions/*": null
    	},
    	"imports": {
    		"#calc": "calculus",
    		"#derivative": "calculus/derivative"
    	},
    	"dependencies": {
    		"calculus": "1.0.0"
    	}
    }

Based on that example, instead of writing out the relative path to derivative.js every time you want to import it in the math application, you can use the `#derivative` shorthand instead. Subpaths can also be used in the imports field to use shorthand for dependencies, such as `#calc`.

    import { derivative } from '#derivative';
    import * as calculus from '#calc';

## Adding third-party libraries {#javascript-modules-third-party-libraries__section_zs1_hkt_pzb}

Applications must declare dependencies on third-party libraries to use their module code. In an application's package.json file, include the package name and version for any dependencies. For example, to use modules from the "math" library in the "test" application, add the "math" package as a dependency:

    {
    	"name": "test",
    	"version": "1.0.0",
    	"dependencies": {
    		"math": "1.0.0"
    	}
    }

## Importing server APIs {#javascript-modules-third-party-libraries__section_pn3_lsk_cfc}

To import server APIs and use them in a module, use import statements. Glide APIs can be imported from the `@servicenow/glide` package or their namespace in the package.  
For example:

    import { API } from '@servicenow/glide';
    import { API } from '@servicenow/glide/<namespace>';

In the following example, the gs (GlideSystem) and GlideRecord APIs are imported in a module:

    import { gs } from '@servicenow/glide';
    import { GlideRecord } from '@servicenow/glide';

In the following example, the RESTAPIRequest and RESTAPIResponse APIs are imported from the `sn_ws_int` namespace in a module because they run in that namespace:

    import { RESTAPIRequest, RESTAPIResponse } from '@servicenow/glide/sn_ws_int';

To access server APIs in a third-party library module, you must add the module as a trusted module with the trustedModules parameter in your application's
now.config.json file. For more information, see [Custom application configuration in source code](https://www.servicenow.com/docs/wYv5gXCGDQIMsHXBPpwpjA "Configure a custom application [sys_app] in the now.config.json file for an application in source code.").

For more information about available server APIs, see [Server API reference](https://www.servicenow.com/docs/access?context=api-server&version=brazil&pubname=brazil-api-reference&ft:locale=en-US).

## Importing script includes {#javascript-modules-third-party-libraries__section_tvf_rw5_mhc}

To import script includes and use them in a module, use import statements. Script includes can be imported from their application scope or the global scope in the `@servicenow/glide` package.  
For example:

    import { global } from '@servicenow/glide/global';
    import { ScriptInclude } from '@servicenow/glide/<scope>';

For more information about script includes, see [Script includes](https://www.servicenow.com/docs/access?context=c_ScriptIncludes&version=brazil&pubname=brazil-api-reference&ft:locale=en-US).
**Related tasks**   

* [Create and use JavaScript modules in applications in the ServiceNow IDE](https://www.servicenow.com/docs/xbAkHOR1x1Q3Ua5mXGi_VQ "Optimize your codebase by defining reusable code blocks with JavaScript modules in the ServiceNow IDE.")
* [Create and use JavaScript modules in applications with the ServiceNow SDK](https://www.servicenow.com/docs/2AN3dRek2Ee~e0UyAKRImw "Optimize your codebase by defining reusable code blocks with JavaScript modules and the ServiceNow SDK.")

