How to use verdaccio to create private npm registry?
npm i -g verdaccio
npm set registry http://localhost:4873
-
verdaccio
// to start verdaccio npm adduser --registry http://localhost:4873
- type http://localhost:4873 in bowser adress bar and enter
-
revise verdaccio config file
- open a terminal
gedit /home/abby/.config/verdaccio/config.yaml
- add line
max\_body\_size: 1000mb
in the bottom line. // Set enough large size so that we can publish large package - change all
access:@all
toaccess:$authenticated
- restart verdaccio
verdaccio
- check our current registry
npm get registry
- publish packages in specific registry
npm publish --registry http://111.11.11.111
- remove package if has mistakes
npm unpublish --force myLibrary
How to start verdaccio with systemd?
-
find out verdaccio installed path
npm list verdaccio -g
-
needs to link
node
, since I usednvm
to install nodejs, or will startverdaccio.service
failed and get error:/usr/bin/env: ‘node’: No such file or directory
when debug service with journalctl _SYSTEMD_UNIT=verdaccio.servicesudo ln -s /home/abby/.nvm/versions/node/v13.0.1/bin/node /usr/bin/node
-
update verdaccio.service, it is in "
~/.nvm/versions/node/v13.0.1/lib/node_modules/verdaccio/systemd"
ExecStart=/home/abby/.nvm/versions/node/v13.0.1/lib/node_modules/verdaccio/bin/verdaccio --config /etc/verdaccio/config.yaml
-
Copy verdaccio config to
etc
foldersudo cp -RT /home/abby/.config/verdaccio/ /etc/verdaccio/
-
copy verdaccio.service to /lib/systemd/system/ folder and restart system service
sudo cp /home/abby/.nvm/versions/node/v13.0.1/lib/node\_modules/verdaccio/systemd/verdaccio.service /lib/systemd/system/ && sudo systemctl daemon-reload
verdaccio config file: config.yaml
# 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/verdaccio/verdaccio/tree/master/conf
#
# path to a directory with all packages
storage: /home/abby/.local/share/verdaccio/storage
# path to a directory with plugins to include
plugins: ./plugins
web:
title: Verdaccio
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
enable: true
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
ldap:
type: ldap
# Only required if you are fetching groups that do not have a "cn" property. defaults to "cn"
groupNameAttribute: "ou"
# Optional, default false.
cache:
# max credentials to cache (default to 100 if cache is enabled)
size: 100
# cache expiration in seconds (default to 300 if cache is enabled)
expire: 300
client_options:
url: "ldaps://ldap.example.com"
# Only required if you need auth to bind
adminDn: "cn=admin,dc=example,dc=com"
adminPassword: "admin"
# Search base for users
searchBase: "ou=People,dc=example,dc=com"
searchFilter: "(uid={{username}})"
# If you are using groups, this is also needed
groupDnProperty: 'cn'
groupSearchBase: 'ou=groups,dc=myorg,dc=com'
# If you have memberOf support on your ldap
searchAttributes: ['*', 'memberOf']
# Else, if you don't (use one or the other):
# groupSearchFilter: '(memberUid={{dn}})'
# Optional
reconnect: true
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
# scoped packages
access: $authenticated
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
'**':
# 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: $authenticated
# allow all known users to publish/publish packages
# (anyone can register by default, remember?)
publish: $authenticated
unpublish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs
# You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough.
server:
keepAliveTimeout: 60
middlewares:
audit:
enabled: true
# log settings
logs:
- { type: stdout, format: pretty, level: http }
#- {type: file, path: verdaccio.log, level: info}
#experiments:
# # support for npm token command
# token: false
# Set enough large size so that we can publish large package
max_body_size: 1000mb
verdaccio.service
[Unit]
Description=Verdaccio lightweight npm proxy registry
[Service]
Type=simple
Restart=on-failure
User=abby
ExecStart=/home/abby/.nvm/versions/node/v13.0.1/lib/node_modules/verdaccio/bin/verdaccio --config /etc/verdaccio/config.yaml
[Install]
WantedBy=multi-user.target
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。