搭建自己或公司的私有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文件存储的位置,每个版本清晰可见


Host, Publish and Manage Private npm Packages with Verdaccio

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,127评论 19 139
  • 描述 npm从以下来源获取配置值,按优先级排序: 命令行标记 在命令行上放置--foo bar设置foo配置参数为...
    竹天亮阅读 44,262评论 0 8
  • 原文地址 https://github.com/jindada/blog/issues/1 为什么需要搭建私有np...
    金_大_大阅读 1,859评论 0 6
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,993评论 6 342
  • 今天终于画了一幅画!不容易,已经欠了五副了,下周休息多多补! 明天又周一了……八月要来了!我要28了……
    只一点阅读 416评论 0 0