Use the ServiceNow SDK command-line interface (CLI) to manage changes between a local application and the application on an instance.

From the command-line tool on your system, enter now-sdk to start the CLI and return a list of available commands or now-sdk [command] to begin using the ServiceNow SDK.

The CLI includes the following commands and global options:

Table 1. Global options
Option Description
--version Return the version of the CLI.
--help, -h Return information about commands, subcommands, and parameters.
--debug, -d Return the debug logs generated with a command.

upgrade

Upgrade to the latest version of the ServiceNow SDK for use with instances beginning with the Washington DC release.

Upgrading the ServiceNow SDK doesn't update any applications you have previously created or converted with the ServiceNow SDK.

The upgrade command has the following structure:
now-sdk upgrade [--debug <flag>]
For example:
now-sdk upgrade --debug true

For more information, see Upgrade the ServiceNow SDK.

auth

Authenticate to an instance and store, update, or view user credentials for accessing an instance on your system.

The auth command has parameters for adding credentials, deleting credentials, listing credentials, and setting credentials to use by default.

For more information, see Authenticating to a ServiceNow instance with the ServiceNow SDK.

add

Store credentials in the device keychain or credential manager on your system.

The auth command has the following structure with the --add parameter:
npx @servicenow/sdk auth [--add <instance url>] [--type <auth method>] [--alias <alias>]
Note: Using the npx command installs the ServiceNow SDK in your application directory instead of globally.
Table 2. Required parameters
Parameter Type Description Default value
--add String The URL of the target instance to access and to which you install applications. The instance must be on the Washington DC release or later.
Table 3. Optional parameters
Parameter Type Description Default value
--type String The method to use to authenticate with the target instance. Specify basic for basic authentication or oauth for OAuth 2.0 authentication. basic
--alias String The alias for the instance and user credentials.

The alias can be used for authentication with the init, transform, dependencies, and install commands.

For example:
npx @servicenow/sdk auth --add https://myinstance.service-now.com --type oauth --alias devuser1

delete

Remove credentials in the device keychain or credential manager on your system.

The auth command has the following structure with the --delete parameter:
now-sdk auth [--delete <alias or all>]
Table 4. Required parameters
Parameter Type Description Default value
--delete String

The alias for the instance and user credentials.

To delete all credentials, set this parameter to --delete all.

For example:
now-sdk auth --delete devuser1

list

View credentials saved in the device keychain or credential manager on your system. Passwords and authentication codes aren't returned.

The auth command has the following structure with the --list parameter:
now-sdk auth [--list]
Table 5. Required parameters
Parameter Type Description Default value
--list String Lists all available authentication credentials.
For example:
now-sdk auth --list

use

Set the credentials to be used by commands by default.

The auth command has the following structure with the --use parameter:
now-sdk auth [--use <alias>]
Table 6. Required parameters
Parameter Type Description Default value
--use String The alias for the instance and user credentials.
For example:
now-sdk auth --use devuser1

init

Create a custom scoped application or convert an existing scoped application to support development in source code. The application is added in the current directory.

To create an application with your default credentials, you can run the init command without any optional parameters. For example, now-sdk init. To convert an existing application, you must include the --from parameter to provide the sys_id of an application on an instance or a path to a local directory that contains an application.

After initializing an application, you must install the required third-party dependencies using your preferred package manager before building the application. For example, if you use Node Package Manager (npm), run npm install.

The init command has the following structure:
npx @servicenow/sdk init [--from <sys_id or path>] [--appName <name>] [--packageName <name>] [--scopeName <name>] [--auth <alias>]
Note: Using the npx command installs the ServiceNow SDK in your application directory instead of globally.
For example:
npx @servicenow/sdk init --from dbce0f6a3b3fda107b45b5d355e45af6 --appName Example App --packageName example-app --scopeName x_snc_example --auth devuser1

For more information, see Create an application with the ServiceNow SDK or Convert an application with the ServiceNow SDK.

build

Compile source files and generate an installable package. Third-party library dependencies are converted into XML files that can be installed with the application.

The build command has the following structure:
now-sdk build <source> [--frozenKeys <flag>]
Table 8. Optional parameters
Parameter Type Description Default value
source String The path to the package.json file for your application.

The package.json should be in the base directory of your application.

Current working directory
--frozenKeys Boolean Validates that the keys.ts file is up to date for continuous integration (CI) builds. If true and changes were made to the application's ServiceNow Fluent code, the keys.ts file isn't updated and the build fails.

The keys.ts file is automatically generated in the src/fluent/generated directory.

false
For example:
now-sdk build /path/to/package --frozenKeys true

For more information, see Build and install an application with the ServiceNow SDK.

install

Install or update an application on an instance. Before using the install command, you must use the build command to generate an installable package.

The install command has the following structure:

now-sdk install [--source <package path>] [--reinstall <flag>] [--auth <alias>] [--open-browser <flag>] [--info <flag>]
For example:
now-sdk install --source /path/to/package --reinstall false --auth devuser1 --open-browser true --info true

For more information, see Build and install an application with the ServiceNow SDK.

transform

Download application metadata (XML) from the instance and transform the metadata into ServiceNow Fluent source code to synchronize the application changes on the instance into your local application.

After initializing an application, you can run the transform command without any parameters to transform new application metadata from the instance into source code in the src/fluent/generated directory and synchronize changes to metadata into source code in the src/fluent directory. To transform metadata that existed when the application was initialized into source code, use the --from parameter to provide the path to a local directory or file that contains XML. If metadata exists in the local application as both XML and source code, the XML version takes precedence when installed on the instance.

The transform command has the following structure:
now-sdk transform [--from <path>] [--directory <package path>] [--preview <flag>] [--auth <alias>]
For example:
now-sdk transform --from metadata/update --directory /path/to/package --preview true --auth devuser1

For more information, see Convert an application with the ServiceNow SDK or Build and install an application with the ServiceNow SDK.

dependencies

Download the application dependencies configured in the now.config.json file and script dependencies, such as TypeScript type definitions for Glide APIs and script includes, from the instance.

To generate and download any tables on which your application depends, you must configure dependencies in the now.config.json. After downloading script dependencies, you must update your tsconfig.json file to include the type definitions.

The dependencies command has the following structure:

now-sdk dependencies [--directory <package path>] [--auth <alias>]
Table 11. Optional parameters
Parameter Type Description Default value
--directory String The path to the package.json file for your application.

The package.json should be in the base directory of your application.

Current working directory
--auth, -a String An alias for the credentials to use to authenticate to the instance. If set, the default alias.
For example:
now-sdk dependencies --directory /path/to/package --auth devuser1

For more information, see Downloading application and script dependencies with the ServiceNow SDK.