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.
Open CODING-AR
1. Log in to the CODING Console and click Use Now to go to CODING page.
2. Click in the upper-right corner to open the project list page and click a project icon to open the project. 3. In the menu on the left, click Artifact Management.
Preparations
Note:
Before you begin:
Install Node.js.
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.
2. Initialize the npm project.
Enter the npm configuration in the new package.json
when asked. For example:
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "",
"license": "MIT"
}
3. Create a .npmrc
file.
Authentication information must be configured before you can pull artifacts from or push artifacts to CODING-AR.
Configure authentication information in either of the following ways:
Set credentials with the configuration file
Set credentials with the interactive command line
Method 1: setting credentials with configuration file
1. On the guide page, click Generate configuration from access token and enter the account login password in the pop-up window.
2. Copy the configuration to the .npmrc
file in the same directory as your project's package.json
.
Method 2: set credentials with interactive command line
1. Copy and run the npm config
to set the npm registry
to the current artifact repository.
2. Run npm login
and enter the account, password, and email address when asked.
Push an npm Artifact
Copy and run the push command on the page to push a local artifact to the remote repository.
npm publish --registry=<Repository URL in the Push Guide>
After the artifact is pushed successfully, refresh the page to view the latest artifacts.
Pull an npm Artifact
Copy and run the npm install
command to pull an artifact:
npm install <Package Name> --registry=<Repository URL in the Pull Guide>
After the artifact is pulled, you can see a success message.
If you try to pull an artifact that does not exist in the CODING private repository, the system will try to pull from the configured proxy. You can add a third-party artifact source to obtain artifacts from the specific repository. Without the need for configuration, CODING will retrieve artifacts in sequence from top to bottom.
Replace <package>
with the package name and run the command generated on the page to pull the package.
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.
Was this page helpful?