Environment to prepare
- centos7.6
- docker
Nexus3 deployment
- Pull the mirror
docker pull sonatype/nexus3
Copy the code
- 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
- 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
- Add the project root directory
.npmrc
file
_auth is base64 of username:password
Registry _auth = ZGVwbG95ZXI6ZGVwbG95ZXI = = http://127.0.0.1:8081/repository/npm-groupCopy the code
- Clear the cache
npm cache clean -f
Copy the code
Publishing private packages
⚠️ Notice The private package address is Hosted, not Group or proxy
-
Use commands directly to associate warehouse publishing
npm publish --registry=http://localhost:8081/repository/npm-hosted/
Copy the code
-
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