In daily work, there are often some projects we can not easily host on GitHub, NPM, this above, a private package management platform is particularly important! Cut to the chase and start with the hero of the day, Sinopia.
1. Install Sinopia
npm install -g sinopia
Copy the code
2. Configure sinopia
I was set up on The Ali cloud server (Ubantu), and the next steps were all operated on the Ali cloud.
/root/.config/sinopia/config.yaml
Copy the code
Open the above file and change it to the following:
#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/rlidwka/sinopia/tree/master/conf
#
# path to a directory with all packages
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
max_users: 1000
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npm.taobao.org
packages:
'@ * / *':
# scoped packages
access: $all
publish: $authenticated
The '*':
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $all
# allow all known users to publish packages
# (anyone can register by default, remember?)
publish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs
# log settings
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: sinopia.log, level: info}
# add
max_body_size: '200mb'
listen: 0.0. 0. 0: 4873
Copy the code
3. Install the PM2
npm install -g pm2
Copy the code
4. Run Sinopia
You can run it directly
sinopia
Copy the code
But you don’t want the process to be logged out as soon as you close CMD.
pm2 start sinopia
Copy the code
Open IP ::4873 and see the following:
5, modify sinopia permissions into the directory (/ root/config/sinopia/storage)
chmod 777 .sinopia-db.json
Copy the code
At this point, the server configuration is complete. Next is how to distribute and install locally.
6. Install NRM (NPM source management)
npm install -g nrm
Copy the code
7. Add sinopia source
NRM add sinopia http://127.0.0.1:4873Copy the code
View existing NPM sources
nrm ls
Copy the code
8. Switch to Sinopia
nrm use sinopia
Copy the code
Before publishing a package, you need to register and log in to a user
(1) Registered users
npm adduser
Copy the code
Next, you will be prompted to enter username, password, email, according to their own situation can be entered!
(2) Login user
npm login
Copy the code
Also according to the prompt to enter the information just registered.
10. Publish to the project root directory
npm publish
Copy the code
11, installation,
npm install --save XXX
Copy the code