tencent cloud

Feedback

npm Repository

Last updated: 2022-03-30 10:08:16

    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.
    • Create an artifact repository (see Basic Operations).
    • 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
      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.
      touch .npmrc

    Configure Authentication Information

    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.
      npm login

    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.

    Configure a Proxy

    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.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support