Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to build npm private server based on Nexus 3

Shulou Source: shulou.com Published: 2022-06-01 14:40:42 09月30日 Update

This article will explain in detail how to build a npm server based on Nexus 3. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Create Repository

Nexus Repository Manager 3 can be used for many types of package management. Due to the need of work, you need to configure Nexus 3-based npm package management.

Nexus default account: admin/admin123

Select configuration page

Select the Repositories on the left

Click the Create repository function

You will see the repository types supported by Nexus 3. You should be familiar with Java developer maven2.

If you look closely, you will find that each repository contains three types that can be created, group and hosted,proxy. The following is an explanation of each:

Proxy

According to the name of proxy, you can imagine that this type of repository is used to act as an agent. For example, if we are building a Maven private server and need to connect with the central database, we need to use proxy to create a repository. See the maven- Central library for Nexus mode.

Hosted

This repository can be simply understood as a private, internal repository. Some of the tools and component libraries developed in our work are not convenient to put into the central library, but they need to be shared within the company, so we need to create a hosted type repository for publishing components within the company. See maven-releases, maven-snapshots.

Group

Finally, let's talk about the group type. In fact, this type is a virtual repository, which is used to combine the repository of proxy and hosted types into one, which is convenient for users. For example, maven-public contains not only maven-central, but also maven-releases and maven-snapshots, so that no matter it is the jar package of the online central library or the jar released by ourselves, it can be obtained through maven-public.

Combined with the experience of maven repository configuration, the same routine configuration is used for npm repository.

Configure the proxy library

In the configuration interface of proxy type, it is found that Name and Remote storage are required. Name can be filled in at will. Remote storage needs to fill in an address similar to the central library of maven. Here npm chooses the private server address https://registry.npm.taobao.org of Taobao.

Configure the hosted library

Hosted library configuration is relatively simple, you only need to fill in name.

Configure the Group library

In the group configuration, name is also required. In addition, there is an additional configuration of members, adding the npm-hosted,npm-proxy on the left to the members on the right, so that resources in the npm-hosted,npm-proxy can be accessed simultaneously through group.

Publish to npm private server

First, you need to configure permissions to enable npm Bearer Token Realm.

Configure the local npm login

Npm login-- registry= http://localhost:8888/repository/npm-hosted/

Then enter the user name and password, mailbox, and if successful, a record will be generated in the .npmrc file.

/ / localhost:8888/repository/npm-hosted/:_authToken=NpmToken.16b06a38-cae5-32ca-8a5f-2310ef16e156

On the premise of ensuring that the project has package.json, execute:

Npm publish-- registry= http://localhost:8888/repository/npm-hosted/

The sent npm components can be queried in the private server.

On how to build a Nexus 3-based npm private server to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Configuration type private server central component selection company content can be passed at the same time address article more knowledge article work development management yes user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Information MySQL Microsoft MariaDB