sinopia搭建npm私服&包开发

本文详细介绍如何使用Sinopia搭建npm私有服务器,包括安装配置、守护进程设置及客户端使用方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

搭建npm服务器

1.安装sinopia

npm install sinopia -g
复制代码

安装完成后执行:

sinopia
复制代码

输出:

warn  --- config file  -  C:\Users\Administrator\.config\sinopia\config.yaml
warn  --- http address - http://localhost:4873/
复制代码

执行成功,打开 http://localhost:4873/ 可以看到类似npm官网的界面,此时npm私服搭建成功!

2.node进程守护工具:pm2。

这里不赘述,可参考:segmentfault.com/a/119000000…

3.sinopia配置文件

step1中控制台输出的配置文件: C:\Users\Administrator.config\sinopia\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/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.npmjs.org/

packages:
  '@*/*':
    # scoped packages
    access: $all
    publish: $authenticated

  '*':
    # 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}

复制代码

客户端使用

1.创建用户

npm adduser --registry http://localhost:4873/
复制代码

按提示依次输入用户名、密码、邮箱。

2.发布包

npm publish --registry http://localhost:4873/
复制代码

3.安装包(test为包名)

npm install --registry http://localhost:4873/ test --save
复制代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值