Install an npm package from a private registry with the ServiceNow IDE
Install Node Package Manager (npm) packages from a private registry as dependencies in your application to use them as third-party libraries.
Before you begin
Role required: admin
About this task
To install packages from private registries, you must configure your Package Manager user settings in the ServiceNow IDE. Then you can choose in which applications to install packages.
ServiceNow IDE uses the public npm registry (https://registry.npmjs.org) as its default package source. If your network blocks access to this registry, you must have access to an alternate registry to download packages and build applications in the ServiceNow IDE. If access to the public npm registry is blocked on your system, you must configure a private npm registry in your Package Manager user settings in the ServiceNow IDE.
Note: To install packages from a private registry, the registry must respond with the HTTP Access-Control-Allow-Origin header.
Procedure
Navigate to All > App Development > ServiceNow IDE.
Open a workspace.
Use one of the following keyboard shortcuts to open the command palette:
- Windows: Ctrl-Shift-P
- Mac: Cmd-Shift-P
- Enter
Preferences: Open User Settings (JSON)and press Enter.
Specify a private registry as the default registry or a scoped registryfrom which you can install packages.
| Option | Example |
|---|---|
| Default registry | |
| Scoped registry | |
**Note:** To install packages from public registries, you can specify a public registry as the default registry or a scoped registry in addition to any private registries.
- Provide your credentials for accessing the private registry.
| Basic authentication | Provide a user name and password to access the default registry that you specified. |
| Legacy authentication | Provide a legacy token to access the default registry that you specified. Legacy tokens are basic authentication credentials encoded in Base64 format. |
| Token authentication | Provide a bearer token to access the default registry that you specified. |
Save your changes to the
settings.jsonfile.Install packages from the configured registries.
Use one of the following keyboard shortcuts to open the command palette:
- Windows: Ctrl-Shift-P
- Mac: Cmd-Shift-P
- Enter
Package Manager: Install Dependenciesand press Enter.
- Enter
Select an application to install packages in as dependencies.
Packages are installed in the
node_modulesdirectory.
User settings for private registry access
In the following example, a user configured access to a private registry using basic authentication. The user also configured their settings to install packages from a public registry with the @example scope.
{
"files.autoSave": "off",
"package-manager.defaultRegistry": "<private-registry-url>",
"package-manager.basicAuth": [
{
"registry": "<private-registry-url>",
"user": "<user-name>",
"pass": "<password>"
}
],
"package-manager.scopedRegistries": [
{
"scope": "@example",
"registry": "<public-registry-url>"
}
]
}
What to do next
Use the packages that you installed as third-party libraries in your application. For more information, see Use third-party libraries in applications in the ServiceNow IDE.
Parent Topic:Use third-party libraries in applications in the ServiceNow IDE