One, foreword
Many times, companies may not want to open source their code for security, privacy or other reasons, so they build their own private repositories. Currently, the common front-end package manager is the public repository of NPM. Since the department currently uses Nexus2 to manage back-end JAR packages, it uses Nexus2 to build the NPM private repository.
2. Set up the Nexus2 private warehouse
Build process is omitted (specific reference: blog.csdn.net/xixiaoxie2/…).
The nexus2 supports three types of private libraries
- Proxying NPM Registries proxy repository
The warehouse can remote access to public warehouses, the current setting of the register to https://registry.npm.taobao.org
The server caches downloaded packages.
Only packages from public repositories can be downloaded.
- Private NPM Registries managed repository
The repository is a private repository and can publish its own code packages and download packages already published in the private repository.
- Grouping NPM Registries repository group
By combining the first two separate repositories, you can download packages from both the public repository and the private repository.
Use a private repository for local configuration
After the private warehouse is built, we can use the warehouse, before using, we need to configure a wave.
First, we register a private warehouse account
Then assign permissions. This operation is best performed by the highest permission account admin.
Then use NPM config ls to view the NPM configuration
register
By default,http://registry.npmjs.org
Register and Registry can be ignored and are described later.
HOME
To see theHOME
Is there one under the path.npmrc
The configuration file
npmrc
file
npm config setEmail "[email protected]" NPM configset always-auth true
npm config set _auth "ROY***********=="Copy the code
email
Is the mailbox bound to the login user
_auth
It’s for the username and passwordbase64
The code format is user name: password
4. Release private repository on code package:
npm
theregistry
Need to change to the path you publish
npm publish
addregistry
Option or when you need to publish the packagepackage.json
Configuration in file
- package.json
- index.js
- REDME.md
package.json
throughnpm init
Initialize out
NPM config set registry
Download packages from a private repository
npm
theregister
configuration
It can also be modified permanently:
npm config set -register "http://****"Copy the code
npm -loglevel info install testCopy the code
Here you can enjoy the use of the company’s internal private storage ~
This article reference www.cnblogs.com/wfeicherish…
And finally… Novice on the road, will inevitably bump bump, if where write bad or careless, welcome to point out at any time, learn together.
Come on!!