Use third-party libraries in applications with the ServiceNow SDK

  • 릴리스 버전: Australia
  • 업데이트 날짜 2026년 03월 12일
  • 소요 시간: 3분
  • Call third-party libraries in your application to use existing open-source functionality with the ServiceNow SDK.

    시작하기 전에

    Create a JavaScript module. For more information, see Create and use JavaScript modules in applications with the ServiceNow SDK.

    Role required: admin

    이 태스크 정보

    Third-party libraries are added to applications as JavaScript modules. For general information about the syntax used to create JavaScript modules, see the JavaScript modules page on the MDN Web Docs website.

    중요사항:
    You can't use third-party libraries that rely on unsupported functionality, such as unsupported APIs or ECMAScript features. For more information about unsupported functionality, see Third-party library support in Australia and JavaScript modules and third-party libraries.

    프로시저

    1. In Visual Studio Code, open your scoped application directory.
    2. From the application directory, open an integrated Terminal window.
    3. Install the npm package for the library.
      npm install <package name>
      The library's packages are added to your application in the node_modules directory, and the library is added as a dependency in the package.json file for the application.
      "dependencies": {
          "<package name>": "<version>"
        }
    4. In a JavaScript module, import the library using an import statement.
      In this example, the module includes a namespace import for the lodash module.
      import * as lodash from "lodash"

      In this example, the module includes a named import for the camelCase function in the lodash module.

      import camelCase from 'lodash'
    5. Call code imported from the library in your module to reuse it.

    다음에 수행할 작업

    Build and install your changes on an instance. For more information, see Build and install an application with the ServiceNow SDK.