The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Npm

Last updated: 2026-04-03 17:16:15

This document describes how to store npm artifacts in CODING-AR for centralized artifact management and version control. The following sections introduce how to create an artifact, configure authentication, and pull and push artifacts.
Note:
To read this document, prepare the following:
Install Node.js.
<Basic Operations>—Create a project.
Select npm as the repository type.

Initialize a Local npm Project (Optional)

You can skip this section if you are familiar with npm artifacts.
1. Create a demo directory for the npm project.
mkdir npm-demo
2. Initialize the npm project.
cd npm-demo && npm init
Follow the prompts to fill in the configuration file of the npm package in the newly added package.json.
For example:
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "",
"license": "MIT"
}
3. Create a .npmrc file.
touch .npmrc

Configure Authentication Information

Configure authentication before pushing or pulling an artifact.
Configure authentication information in either of the following ways:
Set credentials with the configuration file
Set credentials with the interactive command line

Method 1: Set credentials using a configuration file

1. On the artifact repository guide page, enter the password and click Generate Personal Token as a credential.



2. Copy the interactive command line instructions newly added to the page, and add them to the .npmrc file in the same directory as your project's package.json.




Method 2: Set credentials using interactive command line

Follow the page instructions to configure credentials in the local artifact repository.




Push an Artifact

Enter the artifact name and version in the web guide, initialize first, and then push the artifact as prompted.



After the artifact is pushed successfully, refresh the page to view the latest artifacts.




Pull an Artifact

Enter the artifact name and version in the guide to auto-generate the pull command.



After the artifact is pulled, you can see a success message.




Configure a Proxy

If the desired artifact is not hosted in the CODING Artifact Repository, it will attempt to pull from the configured proxy address. You can add a third-party artifact source to get artifacts from a specific repository. No additional settings are needed; the repository will sequentially retrieve the respective artifact packages.



Use the pull command in the operation guidelines, replace the package name in <package>, to complete the pull.



The artifact and its dependencies will be pulled to the local machine and synchronized to CODING-AR. The package source will be shown on the details page.



For more information, see Artifact Repository Proxy.