You can publish npm packages to Artifactory using either Yarn V2+ (Modern) or Yarn V1 (Classic).
Publish npm Packages with Yarn V2+ (Modern)
You can publish npm packages to Artifactory using Yarn Modern by running the publish command from a package folder.
To publish npm packages to Artifactory with Yarn Modern:
Run the following command from the package folder:
yarn npm publish
Configure Yarn to publish packages to Artifactory by adding the target repository to the package.json file. You can also specify the target repository in the yarn publish command to override the configured target repository.
To publish a package to Artifactory:
Add the following snippet to the
package.jsonfile:"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:
yarn publish
Tip
You can also publish to a specific repository using the
--registryflag to specify the full repository URL after the publish command. For example,yarn publish --registry https://company.jfrog.io/artifactory/api/npm/npm-local/.