搭建自己或公司的私有npm仓库

verdaccio/verdaccio这个很好搭建,再加上docker更是方便。

  1. .npmrc配置项的使用

安装 node-sass 的时候总是会各种不成功
lmk123/blog 安装 node-sass 的正确姿势

registry=http://localhost:4873/注册本地仓库,拉代码的话会首先去这里查找,找不到就回去https://www.npmjs.com/查找
npm publish代码的话也会将代码发布到.npmrc配置的私有仓库
verdaccio官网推荐的命令行方式: npm publish --registry http://localhost:4873
配置.npmrc的话就省去了后面参数的书写

之前在docker上安装了verdaccio,并发布了一个项目到上面可是重启后,数据丢失,就是没有保存到磁盘上,今天安装到了我的windows上面,通过localhost:4873,但是我的mac没法访问,即使通过windows电脑的http://192.168.0.107:4873也没法访问,查阅了verdaccio/conf/full.yaml发现这么是可以配置的

# You can specify listen address (or simply a port).
# If you add multiple values, verdaccio will listen on all of them.
#
# Examples:
#
#listen:
# - localhost:4873            # default value
# - http://localhost:4873     # same thing
# - 0.0.0.0:4873              # listen on all addresses (INADDR_ANY)
# - https://example.org:4873  # if you want to use https
# - [::1]:4873                # ipv6
# - unix:/tmp/verdaccio.sock    # unix socket

然后在我的C:\Users\Assassin\AppData\Roaming\verdaccio\config.yaml文件里增加两行配置,重启verdaccio,在mac上顺利的访问了windows的verdaccio仓库

storage: ./storage
auth:
  htpasswd:
    file: ./htpasswd
uplinks:
  npmjs:
    url: 'https://registry.npmjs.org/'
packages:
  '@*/*':
    access: $all
    publish: $authenticated
    proxy: npmjs
  '**':
    access: $all
    publish: $authenticated
    proxy: npmjs
logs:
  - type: stdout
    format: pretty
    level: http
listen://新增
  - localhost:4873
  - http://192.168.0.107:4873

上面的storage标明了我publish文件存储的位置,每个版本清晰可见


搭建自己或公司的私有npm仓库_第1张图片

Host, Publish and Manage Private npm Packages with Verdaccio

你可能感兴趣的:(搭建自己或公司的私有npm仓库)