Migrating Local npm Registry Data to CodeArts Artifact
A local repository is a copy of software packages or dependencies stored on your computer. When you use npm to manage dependencies, the tools download dependencies from remote repositories to your local repository. However, CodeArts Artifact enforces strict permissions for storing, pushing, and pulling dependencies and final products generated during development to support effective team collaboration. Therefore, after migrating npm registry data from your local disk to CodeArts Artifact, you can manage operations and maintenance more efficiently in one place. To meet this need, CodeArts Artifact provides a tool to help you quickly migrate npm registry data in batches to the npm registry in self-hosted repos.
Constraints
Only local Maven and npm repository data can be migrated to self-hosted repos in CodeArts Artifact. This section describes how to migrate local npm registry data to CodeArts Artifact.
Prerequisites
- You already have a project. If no project is available, create one.
- You have permissions for the current Maven repository. For details, see Configuring Repository Permissions.
- You have created an npm registry in self-hosted repos.
- You have the Python3 environment available.
- The local PC running the migration tool is connected to CodeArts Artifact. That is, the PC can access the network address of CodeArts Artifact. You can use either of the following methods to verify the connection:
- Open a browser and access the repository address of CodeArts Artifact. (For details about how to obtain the repository address, see steps 1 to 3 in Step 1: Obtain Target npm Registry Information from CodeArts Artifact.)
- Run the following command:
telnet Repository address of CodeArts Artifact (For details about how to obtain the repository address, see steps 1 to 3 in Step 1: Obtain Target npm Registry Information from CodeArts Artifact.)
Step 1: Obtain Target npm Registry Information from CodeArts Artifact
- Use your Huawei Cloud account to access self-hosted repos.
- In the left pane, click the target npm registry name to go to its details page and view the Repo URL.
- Click
next to the repository URL to copy it. - Click Tutorial in the upper-right corner of the page. In the displayed dialog box, click Download Configuration File to download the npmrc configuration file to the localhost.

- Open the configuration file on the localhost, find the value of the _auth field, and decode the value using Base64.
Step 2: Configure Migration Scripts
- Use your Huawei Cloud account to access self-hosted repos.
- In the left pane, select the target npm registry.
- Click the repository name. In the upper-right corner of the page, click
and select Download Migration Tool to download the MigrateTool.zip package to the localhost. Then decompress it to obtain uploadArtifact.py (migration tool) and artifact.conf (configuration file). - Configure the artifact.conf file using the example below. Other parameters can be deleted.
[artifact]
packageType =Component type. Set it to npm.
userInfo =Value of the _auth field decoded using Base64 in the npmrc configuration file of the npm registry. (For details, see 5 in Step 1: Obtain Target npm Registry Information from CodeArts Artifact.)
repoRelease =Repository URL (repository URL obtained in 3 of Step 1: Obtain Target npm Registry Information from CodeArts Artifact)
repoSnapshot =Left empty
srcDir =Directory path of the local npm registry to be migrated. The value is user-defined, for example, C:\Users\xxxxxx\repository.
Step 3: Migrate Data
Run the migration tool obtained in 3 by executing this command:
python uploadArtifact.py
Step 4: Verify Migration Results
Go to the target npm registry in self-hosted repos and verify whether the local npm registry data was uploaded successfully.
If the migration fails, try again or contact customer service.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
