之前写过一次利用 cnpm搭建私服,这次试试 verdaccio ,笔记放着

    失败了,不会操作。。。

    利用Verdaccio 搭建npm私服 - 图1

    Verdaccio · 一个开源轻量的npm私服 A lightweight private npm proxy registry Verdaccio 是一种绿色,在中世纪后期的意大利很流行,常用于壁画。

    两种部署方式

    • npm install --global verdaccio then verdaccio 启动
    • docker支持 docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio

    运行

    1. verdaccio --listen 4000 --config /aegisProject/self-npm/config.yaml
    2. npm adduser --registry http://localhost:4000

    设置端口,设定配置文件

    全局修改

    1. # 方案一,手动修改
    2. npm set registry http://localhost:4000
    3. yarn config set registry http:///localhost:4000
    4. # 方案二 nrm 新增配置 推荐
    5. nrm add test http://localhost:4000
    6. nrm use test
    7. # 方案三 项目级别配置 .npmrc
    8. registry=http://localhost:4000

    发包

    1. {
    2. "publishConfig": {
    3. "registry": "http://localhost:4000"
    4. }
    5. }

    配置文件可参考:

    1. #
    2. # This is the default config file. It allows all users to do anything,
    3. # so don't use it on production systems.
    4. #
    5. # Look here for more config file examples:
    6. # https://github.com/verdaccio/verdaccio/tree/master/conf
    7. #
    8. # path to a directory with all packages
    9. storage: ./storage
    10. # path to a directory with plugins to include
    11. plugins: ./plugins
    12. web:
    13. title: Verdaccio
    14. # comment out to disable gravatar support
    15. # gravatar: false
    16. # by default packages are ordercer ascendant (asc|desc)
    17. # sort_packages: asc
    18. # convert your UI to the dark side
    19. # darkMode: true
    20. # translate your registry, api i18n not available yet
    21. # i18n:
    22. # list of the available translations https://github.com/verdaccio/ui/tree/master/i18n/translations
    23. web: zh-CN
    24. auth:
    25. htpasswd:
    26. file: ./htpasswd
    27. # Maximum amount of users allowed to register, defaults to "+inf".
    28. # You can set this to -1 to disable registration.
    29. # max_users: 1000
    30. # a list of other known repositories we can talk to
    31. uplinks:
    32. cnpm:
    33. url: https://registry.npm.taobao.org/
    34. # npmjs:
    35. # url: https://registry.npmjs.org/
    36. packages:
    37. '@aegis/*':
    38. access: $all
    39. publish: $authenticated
    40. '@*/*':
    41. # scoped packages
    42. access: $all
    43. publish: $authenticated
    44. unpublish: $authenticated
    45. proxy: npmjs
    46. '**':
    47. # allow all users (including non-authenticated users) to read and
    48. # publish all packages
    49. #
    50. # you can specify usernames/groupnames (depending on your auth plugin)
    51. # and three keywords: "$all", "$anonymous", "$authenticated"
    52. access: $all
    53. # allow all known users to publish/publish packages
    54. # (anyone can register by default, remember?)
    55. publish: $authenticated
    56. unpublish: $authenticated
    57. # if package is not available locally, proxy requests to 'npmjs' registry
    58. proxy: cnpm
    59. # You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections.
    60. # 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.
    61. # 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.
    62. server:
    63. keepAliveTimeout: 60
    64. middlewares:
    65. audit:
    66. enabled: true
    67. # log settings
    68. logs:
    69. - { type: stdout, format: pretty, level: http }
    70. #- {type: file, path: verdaccio.log, level: info}
    71. #experiments:
    72. # # support for npm token command
    73. # token: false
    74. # # support for the new v1 search endpoint, functional by incomplete read more on ticket 1732
    75. # search: false
    76. # # disable writing body size to logs, read more on ticket 1912
    77. # bytesin_off: false
    78. # This affect the web and api (not developed yet)
    79. #i18n:
    80. #web: en-US

    校验yaml可使用