Configure the npm CLI to publish packages to Artifactory by adding the target repository to the package.json file. You can also specify the repository name in the npm publish command to override the configured target repository.
Note
If you run npm publish without configuring the package.json file, the package publishes to the default repository in the .npmrc file. Configuring the package.json is an optional override to publish a specific package to a different repository.
To set up the npm CLI to publish packages to Artifactory:
Add the following snippet to your package.json file:
"publishConfig":{"registry":"[JFrogPlatformURL]/artifactory/api/npm/<REPO_NAME>/"}Where:
[JFrogPlatformURL]: The URL of your JPD<REPO_NAME>: The name of the target repository
For example:
"publishConfig":{"registry":"https://company.jfrog.io/artifactory/api/npm/npm-local/"}Run the following command:
npm publish
Note
You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.
To publish to a specific repository:
Run the following command:
npm publish --registry [JFrogPlatformURL]/artifactory/api/npm/<REPO_NAME>/Where:
[JFrogPlatformURL]: The URL of your JPD<REPO_NAME>: The name of the target repository
For example:
npm publish --registry https://company.jfrog.io/artifactory/api/npm/npm-local/Note
You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.