Environment to prepare

  • centos7.6
  • docker

Nexus3 deployment

  1. Pull the mirror
docker pull sonatype/nexus3
Copy the code
  1. Start the container
docker run -d -p 8081:8081 sonatype/nexus3
Copy the code

By default, the Nexus JVM has a large amount of memory and may not work, so we can adjust it to a smaller size

docker run -d -p 8081:8081 --name nexus -e INSTALL4J_ADD_VM_PARAMS="-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=/some-other-dir" sonatype/nexus3
Copy the code

See if it works

curl http://localhost:8081/
Copy the code
  1. View password

First we go into the container

docker exec -it contai bash
Copy the code

Viewing the Default Password

cd nexus-data/
vi admin.password
Copy the code

Project configuration

Configuration File Preparation

  1. Add the project root directory.npmrcfile

_auth is base64 of username:password

Registry _auth = ZGVwbG95ZXI6ZGVwbG95ZXI = = http://127.0.0.1:8081/repository/npm-groupCopy the code
  1. Clear the cache
npm cache clean -f
Copy the code

Publishing private packages

⚠️ Notice The private package address is Hosted, not Group or proxy

  1. Use commands directly to associate warehouse publishing

npm publish --registry=http://localhost:8081/repository/npm-hosted/
Copy the code
  1. Add configuration publishing in package.json

{
"publishConfig" : {
    "registry" : "http://localhost:8081/repository/npm-hosted/"}}Copy the code
npm publish
Copy the code

Installing private packages

Viewing Installation Information

npm --loglevel info install react  
Copy the code