Huawei Cloud Yaoyun Server L Instance Evaluation | Best Practices for Enterprise Projects: Private Library Construction Verdaccio (8)

Huawei Cloud Yaoyun Server L instance evaluation | Enterprise project best practice series:

Huawei Cloud Yaoyun Server L Instance Evaluation|Introduction to Cloud Server Best Practices for Enterprise Projects (1)
Huawei Cloud Yaoyun Server L Instance Evaluation|Best Practices for Enterprise Projects Huawei Cloud Introduction (2)
Huawei Cloud Yaoyun Server L Instance Evaluation | Enterprise Project Best Practices Huawei Cloud Yaoyun Server L Instance Introduction (3)
Huawei Cloud Yaoyun Server L Instance Evaluation | Best Practices for Enterprise Projects: Yunyao Cloud Server L Instance Purchase (4)
Huawei Cloud Yaoyun Server L Instance Evaluation | Evaluation of Best Practices for Enterprise Projects Use Case (5)
Huawei Cloud Yaoyun Server L Instance Evaluation|Enterprise Project Best Practice Package Management Tool Installation Software (6)
Huawei Cloud Yaoyun Server L instance evaluation | Enterprise project best practices for docker deployment and application (7)
Huawei Cloud Yaoyun Server L instance evaluation | Enterprise project best practices for private library construction verdaccio (8) a>
Huawei Cloud Yaoyun Server L Instance Evaluation|Enterprise Project Best Practices for Starting the Pet Reservation Project (9)
Huawei Cloud Yaoyun Server L Instance Evaluation|Enterprise Project Best Practice Best Practices of Scheduled Tasks and Queue Queue Practice (10)
Huawei Cloud Yaoyun Server L Instance Evaluation | Best Practices of Enterprise Projects Stress Test (11)
Huawei Cloud Yaoyun Server L instance evaluation | Suggestions and summary of best practices for enterprise projects (12)


9. Huawei Cloud Yao Cloud Server L instance private library construction verdaccio:

Verdaccio is a simple, zero-configuration local private npm package proxy registry. Out of the box, Verdaccio has its own small database, can proxy other registries (such as npmjs.org), and cache downloaded modules.

Build a team's private warehouse to ensure the security, maintenance and privacy of team components, improve public efficiency and reduce team development costs.

Insert image description here


1. Simple npm installation:

# npm全局安装verdaccio
npm i -g verdaccio
# 执行verdaccio
verdaccio  // 发现提示命令找不到
# 查找verdaccio位置
find / -name verdaccio
# 执行verdaccio
/usr/local/node/bin/verdaccio

Insert image description here


2. Install pm2 and start the verdaccio service:

Pain points of traditional Node service management:
At work, I encountered that after the server instance is restarted, each Node service needs to be restarted one by one. Not only is the management cumbersome and inefficient, but it is also easy to miss starting some Node services.

pm2 is a process manager tool for Node applications with load balancing function. You can use it to simplify many tedious tasks of node application management, such as performance monitoring, automatic restart, load balancing, etc. It is used to monitor Node services in the production environment. The status of the program running.

Insert image description here

# 安装pm2
npm install -g pm2
# 执行pm2
pm2    // 发现提示命令找不到
# 查找pm2
find / -name pm2
# 执行pm2
/usr/local/node/bin/pm2

Insert image description here

After opening the external network port 4873 of the server, you can directly use the IP + port of the Huawei Cloud Server L instance server to access the verdaccio service.

Insert image description here

The following is the IP + port of Huawei Cloud Server L instance server to access the verdaccio service:

Insert image description here


3. docker-compose starts the verdaccio service:

The above is a simple installation from npm. In fact, in order to consider the stability of the company, it is recommended to use docker for deployment. The following is the deployment file of docker-compose.

docker-compose.yml file:

version: '3'

networks:
  node-network:
    driver: bridge

services:
  ### Verdaccio Container ###########################
  verdaccio:
    image: verdaccio/verdaccio
    container_name: "verdaccio"
    networks:
      - node-network
    environment:
      - VERDACCIO_PORT=8010
    ports:
      - "8010:8010"
    volumes:
      - "./verdaccio/storage:/verdaccio/storage"
      - "./verdaccio/config:/verdaccio/conf"
      - "./verdaccio/plugins:/verdaccio/plugins"

Insert image description here


4. Initialize the public library warehouse and release the version:

Posted by verdaccio:

npm publish --registry http://124.70.42.136:4873/

Insert image description here

Publish the npm package through npm publish. After publishing, you can see that verdaccio can display the just released package.

Insert image description here

Click to view the detailed information and commands for different installation methods.

Insert image description here


5. Summary:

When we usually use npm publish to publish, the default address of the uploaded warehouse is npm. Use the Verdaccio tool to create a local warehouse address, and then switch the local default upload warehouse address to the local warehouse address. When npm install does not find the local repository, Verdaccio's default configuration will download it from the npm central repository.

Insert image description here

Guess you like

Origin blog.csdn.net/wanmeijuhao/article/details/133818014
Recommended