application-development/servicenow-ide-family-release/tutorial-install-third-party-library-ide.md
On this page
— title: Tutorial part 4: Install and use a third-party library description: Install a third-party library from Node Package Manager (npm) and use it in a JavaScript module. locale: en-US canonical_url: www.servicenow.com/docs/r/australia/application-development/servicenow-ide-family-release/tutorial-install-third-party-library-ide.html release: australia product: ServiceNow IDE (Family Release) classification: servicenow-ide-family-release topic_type: task last_updated: “2026-03-12” reading_time_minutes: 2
breadcrumb: [Getting started: Create your first application in the ServiceNow IDE, Explore, ServiceNow IDE, Building applications in source code, Building pro-code applications, Developing your application, Building applications]
Tutorial part 4: Install and use a third-party library
Install a third-party library from Node Package Manager (npm) and use it in a JavaScript module.
Before you begin
Complete Tutorial part 3: Define a table in ServiceNow Fluent code.
Role required: admin
About this task
Installing third-party libraries allows you to use existing open-source functionality in JavaScript modules to accelerate application development. Then you can refer to JavaScript modules that call third-party code from server-side script definitions in your source code, such as the business rule in the index.now.ts file.
In this example, you install a Lodash library to get common JavaScript utilities and methods. You use one of these methods, snakeCase, in the showStateUpdate function in a sample JavaScript module to display a message string in snake case, which separates words with underscores instead of spaces. In the index.now.ts file, the sample business rule is configured to use the showStateUpdate function for its script and to run after a record is updated in the To-do Items [x_snc_hello_world_to_do] table.
Procedure
-
Install the snakeCase method from the Lodash library in your application.
-
From the Activity Bar, select the File Explorer view ([Omitted image "servicenow-ide-file-explorer-icon.png"] Alt text: File Explorer).
-
Open the
package.jsonfile for the application. -
After the
devDependenciesfield, add thedependenciesfield with the package name and version of the library.}, "dependencies": { "lodash.snakecase": "4.1.1" } } -
For applications that use TypeScript in JavaScript modules, add the lodash.snakecase types to the
devDependenciesfield to get the type annotations for the library."devDependencies": { "@types/lodash.snakecase": "4.1.1", "typescript": "5.5.4", "@servicenow/sdk": "2.2.4", "@servicenow/glide": "26.0.1", "eslint": "8.50.0", "@servicenow/eslint-plugin-sdk-app-plugin": "2.2.4" } -
Save your changes.
-
When prompted, select Install missing dependencies.
Tip: You can also select the Install Dependencies icon ([Omitted image “servicenow-ide-install-deps-icon.png”] Alt text: Install dependencies) or use the
Package Manager: Install Dependenciescommand from the command palette.[Omitted image "servicenow-ide-install-deps.png"] Alt text: Options to install dependencies in the ServiceNow IDE.
Libraries are installed as modules in the
node_modulesdirectory.
-
-
Use code from the Lodash library in a JavaScript module in your application.
-
Navigate to the
src/serverdirectory in your application. -
Open the
script.tssample module. -
In the addInfoMessage method, wrap the message string in the snakeCase method from Lodash to convert it to snake case.
gs.addInfoMessage(snakeCase(`state updated from "${previousState}" to "${currentState}"`)) -
In line 2, add an import for the snakeCase method in the lodash module.
import snakeCase from 'lodash.snakecase'
Note: The global Glide APIs are also imported so that you can use methods like addInfoMessage in your module code.
import { gs } from '@servicenow/glide' -
Save your changes.
-
-
From the Status Bar, select Build and Install.
If the installation completes successfully, the Lodash libraries are added to the EcmaScript Module [sys_module] table, and the
script.tsmodule is updated in the EcmaScript Module [sys_module] table.
Result
After you update any field on a record in the To-do Items [x_snc_hello_world_to_do] table, the sample business rule runs and displays the message in snake case, with the words separated by underscores instead of spaces.
[Omitted image “servicenow-ide-snakecase.png”] Alt text: The message string from the showStateUpdate function in snake case
What to do next
Continue to Tutorial part 5: Clone the application on a different instance.
Parent Topic:Getting started: Create your first application in the ServiceNow IDE
Keep exploring.
Find another answer, or bring this documentation into your own tools.