---
sourceDocument: Australia Build or modify applications
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/application-development

 Release :

    - australia

ft:locale :

    - pt-BR

ft:publication_title :

    - Australia Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# Create and use JavaScript modules

# Create and use JavaScript modules in applications in the ServiceNow IDE {#ariaid-title1}

* Versão de lançamento: Australia
* 
* Atualizado 12 de mar. de 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 min. de leitura

Optimize your codebase by defining reusable code blocks with JavaScript modules in the ServiceNow IDE.

## Antes de Iniciar

Create, convert, or clone an application and add it to your workspace. For more information, see [Adding applications in ServiceNow IDE](https://servicenow-prod.fluidtopics.net/W4AUk0_HXweEPV6SG12kzw "Add applications in the ServiceNow IDE to get started with development in source code.").  
Nota:  
To use TypeScript in modules, select TypeScript as the template type when creating an application.

Create or clone a scoped application with the ServiceNow IDE. For more information, see [Create an application with the ServiceNow IDE](https://servicenow-prod.fluidtopics.net/LSark2Jb1LNJdT8hAz0kWA "Create an application to develop in source code with the ServiceNow IDE.") or [Clone a Git repository with the ServiceNow IDE](https://servicenow-prod.fluidtopics.net/zPOBplNM6ma_Hk0Xu2u9Ag "Clone a remote Git repository to collaborate on applications in source control with the ServiceNow IDE.").

Role required: admin

## Por Que e Quando Desempenhar Esta Tarefa

To learn about support for using JavaScript modules in scoped applications, including some limitations, see [JavaScript modules and third-party libraries](https://servicenow-prod.fluidtopics.net/~ZpTh0ym3z3CLJbh76lA6w "Optimize your code base using JavaScript modules to group related code or add third-party libraries and reuse their code within applications.").
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.  
Nota:  
With Now Assist for Code, you can use the Code autocomplete skill to generate code suggestions for module scripts. For more information, see [Generate code with autocomplete](https://www.servicenow.com/docs/access?context=generate-code-with-autocomplete&version=australia&pubname=australia-api-reference&ft:locale=en-US).

## Procedimento

1. Navigate to AllApp DevelopmentServiceNow IDE.
2. Open a workspace with an application.
3. From the Activity Bar, select the File Explorer view (![File Explorer]()).
4. In the src/server directory of the application, create a JavaScript or TypeScript file to contain the module code you want to reuse.
5. **Opcional:** Import server APIs or script includes to call them from your module.  
   Glide APIs can be imported from the `@servicenow/glide` package or their namespace in the package. Script includes can be imported from their application scope or the global scope in the
   `@servicenow/glide` package.  
   For example:

       import { API } from "@servicenow/glide";
       import { API } from "@servicenow/glide/<namespace>";
       import { ScriptInclude } from "@servicenow/glide/<scope>";
       import { global } from "@servicenow/glide/global";

6. In the module, identify the code to export with export statements.  
   You can use a named export or default export. Named exports can be variables, constants, functions, or classes whereas default exports can be 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 };

7. Use code from the exported module in other modules or server-side scripts.

   | File | Steps |
   | Module | 1. From the src/server directory, create or open a JavaScript module. 2. Import the module code with import statements. The following example is one way that you could import an exported feature in a module: import { feature } from "path/to/module"; Nota: 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'`. 3. Call the module code from this module to reuse it. {#create-use-javascript-modules-ide__ol_vxm_2pm_pzb} |
   | Server-side script in source code | 1. Create or open the definition of application metadata that includes a server-side script, such as a business rule, in source code (.now.ts file). 2. In the script property, import and call the module code to reuse it. You can import a function or provide an inline script. * Import an exported function, function expression, or default function. For example: script: FunctionExport, * Inline scripts must use require statements to import the module code. For example: script: ` const { process } = require('./dist/modules/server/handler.js') process(request, response)`, {#create-use-javascript-modules-ide__ul_ykg_1b1_zbc} For more information about server-side scripts in source code, see [ServiceNow Fluent API reference](https://servicenow-prod.fluidtopics.net/1wC8EsUkf8~4ZcKbxEqDDA "Use ServiceNow Fluent APIs to define the metadata that makes up scoped applications in source code with the ServiceNow IDE or ServiceNow SDK."). {#create-use-javascript-modules-ide__ol_slf_2xz_ybc} |
   | Server-side script record | 1. Open the record for a server-side script, such as a business rule. 2. Import the module code with require statements. The following example is one way that you could import an exported feature in a script: const { feature } = require("path/to/module"); 3. Call the module code from this script to reuse it. {#create-use-javascript-modules-ide__ol_yny_24m_pzb} |
   |-|-|

   {#create-use-javascript-modules-ide__choicetable_kjx_xnm_pzb}
8. Save your changes.
9. From the Status Bar, select Build and InstallBuild and Deploy.  
   ![Build and deploy]()

   The active file that's open in the editor determines which application to build. If no files are open, select the application to build when prompted.  
   After building, the modules are added to the EcmaScript Module \[sys_module\] table.

## O que Fazer Depois

To use third-party libraries in a JavaScript module, see [Use third-party libraries in applications in the ServiceNow IDE](https://servicenow-prod.fluidtopics.net/7xoF_QmvAAYHYnmiFSHdZQ "Call third-party libraries in your application to use existing open-source functionality with the ServiceNow IDE.").
**Conceitos relacionados**   

* [JavaScript modules and third-party libraries](https://servicenow-prod.fluidtopics.net/~ZpTh0ym3z3CLJbh76lA6w "Optimize your code base using JavaScript modules to group related code or add third-party libraries and reuse their code within applications.")

