ARTIFACTORY: One Way to migrate packages from Verdaccio to Artifactory

ARTIFACTORY: One Way to migrate packages from Verdaccio to Artifactory

AuthorFullName__c
Ruilin Fan
articleNumber
000006323
FirstPublishedDate
2025-01-08T13:12:32Z
lastModifiedDate
2025-01-08
VersionNumber
1

Introduction 

One way to finish the migration from Verdaccio to JFrog.

Verdaccio is a lightweight private npm proxy registry created in Node.js, which is ready to be used out of the box, with its own small database that can proxy other registry files (such as npmjs.org) and cache downloaded modules along the way.

After customers purchased Artifactory and used it, they will have the requirement to migrate npm packages from their Verdaccio to Artifactory.

No wiki to support it, so there is a way to migrate npm packages from Verdaccio to Artifactory.

 

Resolution 
  1. Export packages from Verdaccio;

    Default storage path is configured in the conifg.yaml and find it;

    For instance:
    vim config.yaml
    
    *******
    
    storage: ./storage
    
    *******

    You can copy these directories of packages to a temp directory.
  2. Create NPM local repo;

         Click here to know how to create local repo with NPM type;

  3. Import packages into NPM local;

    Use the below shell scripts to export and import;

    a. Fetch all packages’ name and version into packages_list.txt file and here is the script;
     #!/bin/bash
    
    ## Update according to your storage value of config.yaml file.
    VERDACCIO_STORAGE_PATH="./storage"
    
    find $VERDACCIO_STORAGE_PATH -name "package.json" | while read -r package_json; do
    
      package_name=$(jq -r .name < $package_json)
      package_version=$(jq -r .version < $package_json)
      echo "$package_name@$package_version"
    
    done > packages_list.txt  # The .txt will include all package_name@package_version
     

    b. Publish to NPM local repo according to the packages_list.txt and here is the script;
    #! /bin/bash
    
    #Set variables
    ARTIFACTORY_URL="http://localhost:8082/artifactory/api/npm/npm-local/"
    ARTIFACTORY_USER="admin"
    ARTIFACTORY_API_KEY="*****"
    PACKAGES_LIST="packages_list.txt"
    
    
    #Login artifactory
    #npm set registry $ARTIFACTORY_URL
    npm set //localhost:8082/artifactory/api/npm/npm-local/:_authToken=$ARTIFACTORY_API_KEY
    
    #Read list and publish 
    while read -r package; do
            npm pack "$package"
            tarball=$(echo "$package" | sed -e 's/@/-/g' -e 's/\//-/g').tgz
            npm publish "$tarball" --registry $ARTIFACTORY_URL
            rm -rf "$tarball"
    done < "$PACKAGES_LIST"
    

     
Note:

Before running the above scripts, please ensure that you have installed jq and npm, and make modifications based on your actual Artifactory URL, repository name, username, and API Key, etc.