Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ CodeArts Artifact/ Best Practices/ Releasing/Obtaining an npm Component via a Build Task

Releasing/Obtaining an npm Component via a Build Task

Updated on 2025-02-07 GMT+08:00

This section describes how to release a component to an npm repository via a build task and obtain a dependency from the repository for deployment.

Prerequisites

Releasing a Component to an npm Repository

  1. Download the configuration file.

    1. Log in to CodeArts Artifact and access the npm repository. Click Settings in the upper right corner and record the repository path.

    2. Click Cancel to return to the npm repository page. Click Tutorial on the right of the page.
    3. In the displayed dialog box, click Download Configuration File.

    4. Save the downloaded npmrc file as an .npmrc file.

  2. Configure a repository.

    1. Go to Repo and create a Node.js repository. For details, see Creating a Repository. This procedure uses the Nodejs Webpack Demo template.
    2. Go to the repository and upload the .npmrc file to the root directory of the repository. For details, see Uploading Code Files to CodeArts Repo.

    3. Find the package.json file in the repository and open it. Add the path recorded on the Basic Information under the Settings tab page to the name field in the file.

      If the name field cannot be modified, add the path to the Include Patterns field on the Basic Information under the Settings tab page.

  3. Configure and run a build task.

    1. On the Repo page, select a repository and click Create Build Task in the upper right.

      Select Blank Template and click OK.

    2. Add the Build with npm action.

    3. Edit the Build with npm action.
      • Select the desired tool version. In this example, nodejs12.7.0 is used.
      • Delete the existing commands and run the following instead:
        export PATH=$PATH:/root/.npm-global/bin
        npm config set strict-ssl false
        npm publish

    4. Click Save and Run on the right of the page to start the build task.

      After the task is successfully executed, go to the self-hosted repo page and find the uploaded npm component.

Obtaining a Dependency from an npm Repository

The following procedure uses the npm component released in Releasing a Component to an npm Repository as an example to describe how to obtain a dependency from an npm repository.

  1. Configure a repository.

    1. Go to Repo and create a Node.js repository. For details, see Creating a Repository. This procedure uses the Nodejs Webpack Demo template.
    2. Obtain the .npmrc file (see Releasing a Component to an npm Repository) and upload it to the root directory of the repository where the npm dependency is to be used.
    3. Find and open the package.json file in the repository, and configure the dependency to the dependencies field. In this document, the value is as follows:
      "@test/vue-demo": "^1.0.0"

  2. Configure and run a build task.

    1. On the Repo page, select a repository and click Create Build Task in the upper right.

      Select Blank Template and click OK.

    2. Add the Build with npm action.

    3. Edit the Build with npm action.
      • Select the desired tool version. In this example, nodejs12.7.0 is used.
      • Delete the existing commands and run the following instead:
        export PATH=$PATH:/root/.npm-global/bin
        npm config set strict-ssl false
        npm install --verbose

  3. Click Save and Run on the right of the page to start the build task.

    After the task is successfully executed, view the task details. If information similar to the following is found in the log, the dependency has been downloaded from the npm repository.

npm Commands

When configuring build tasks, you can also run the following npm commands as required:

  • Delete an existing component from the npm repository.
    npm unpublish @scope/packageName@version
  • Obtain tags.
    npm dist-tag list @scope/packageName
  • Add a tag.
    npm dist-tag add @scope/packageName@version tagName --registry registryUrl --verbose
  • Delete a tag.
    npm dist-tag rm @scope/packageName@version tagName --registry registryUrl --verbose

Command parameter description:

  • scope: path of a self-hosted repo. For details about how to obtain the path, see Releasing a Component to an npm Repository.
  • packageName: the part following scope in the name field of the package.json file.
  • version: value of the version field in the package.json file.
  • registryUrl: URL of the self-hosted repo referenced by scope in the configuration file.
  • tagName: tag name.

The following uses the component released in Releasing a Component to an npm Repository as an example:

  • scope: test
  • packageName: vue-demo
  • version: 1.0.0

The command for deleting this component is as follows:

npm unpublish @test/vue-demo@1.0.0

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback