使用Sinopia部署私有npm仓库

简介: 使用Sinopia部署私有npm仓库

使用Sinopia部署私有npm仓库

[root@localhost ~]# hostnamectl set-hostname --static npm-server
[root@npm-server ~]# curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash
[root@npm-server ~]# yum install -y nodejs   # 先要有nodejs
[root@npm-server ~]# node -v    # 查看nodejs的版本
v10.21.0
[root@npm-server ~]# npm -v
6.14.4
# 将node源改为淘宝源,有两种方式查看是否修改成功
[root@npm-server ~]# npm config set registry https://registry.npm.taobao.org # 永久修改
[root@npm-server ~]# npm info express
express@4.17.1 | MIT | deps: 30 | versions: 264
Fast, unopinionated, minimalist web framework
http://expressjs.com/
dist
.tarball: https://registry.npm.taobao.org/express/download/express-4.17.1.tgz
.shasum: 4491fc38605cf51f8629d39c2b5d026f98a4c134
dependencies:
accepts: ~1.3.7            depd: ~1.1.2               on-finished: ~2.3.0
array-flatten: 1.1.1       encodeurl: ~1.0.2          parseurl: ~1.3.3
body-parser: 1.19.0        escape-html: ~1.0.3        path-to-regexp: 0.1.7
content-disposition: 0.5.3 etag: ~1.8.1               proxy-addr: ~2.0.5
content-type: ~1.0.4       finalhandler: ~1.1.2       qs: 6.7.0
cookie-signature: 1.0.6    fresh: 0.5.2               range-parser: ~1.2.1
cookie: 0.4.0              merge-descriptors: 1.0.1   safe-buffer: 5.1.2
debug: 2.6.9               methods: ~1.1.2            send: 0.17.1
(...and 6 more.)
maintainers:
- jasnell <jasnell@gmail.com>
- mikeal <mikeal.rogers@gmail.com>
dist-tags:
latest: 4.17.1       next: 5.0.0-alpha.8
published a year ago by dougwilson <doug@somethingdoug.com>
[root@npm-server ~]# npm config get registry
https://registry.npm.taobao.org/
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# 如果想还原npm仓库地址的话,只需要在把地址配置成npm镜像就可以了
[root@npm-server ~]# npm config set registry https://registry.npmjs.org/
# 安装sinopia
[root@npm-server ~]# npm install -g sinopia   # -g表示全局安装,没有-g需要在当前目录下安装
[root@npm-server ~]# sinopia    # 看到下面两行,表示启动成功了
Sinopia doesn't need superuser privileges. Don't run it under root.
 warn  --- config file  - /root/.config/sinopia/config.yaml
 warn  --- http address - http://localhost:4873/
[root@npm-server ~]# cd .config/sinopia/
[root@npm-server sinopia]# ls
config.yaml  storage
[root@npm-server sinopia]# cp config.yaml{,.bak}
[root@npm-server sinopia]# vim config.yaml
listen: 0.0.0.0:4873     # 最后一行添加这一句,不然只能本机访问
# sinopia配置文件详解
#
# 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  # npm包存放的路径
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: -1  # 默认为1000,改为-1,禁止注册
# a list of other known repositories we can talk to
uplinks:
  npmjs:
    url: http://registry.npm.taobao.org/  # 默认为npm的官网,由于国情,修改 url 让sinopia使用 淘宝的npm镜像地址
packages:  # 配置权限管理
  '@*/*':
    # scoped packages
    access: $all  # 表示哪一类用户可以对匹配的项目进行安装 【$all 表示所有人都可以执行对应的操作,$authenticated 表示只有通过验证的人可以执行对应操作,$anonymous 表示只有匿名者可以进行对应操作(通常无用)】
    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  # 如其名,这里的值是对应于 uplinks
# log settings
logs:
  - {type: stdout, format: pretty, level: http}
  #- {type: file, path: sinopia.log, level: info}
# you can specify listen address (or simply a port) 
listen: 0.0.0.0:4873  # 默认没有,只能在本机访问,添加后可以通过外网访问
目录
相关文章
|
前端开发 jenkins 应用服务中间件
使用verdaccio打造自己的npm私有化仓库
使用verdaccio打造自己的npm私有化仓库
566 0
使用verdaccio打造自己的npm私有化仓库
|
4天前
|
JavaScript 前端开发
🚀自定义属于你的脚手架并发布到NPM仓库
🚀自定义属于你的脚手架并发布到NPM仓库
|
安全 NoSQL 关系型数据库
使用cnpm搭建企业内部私有NPM仓库
cnpm是企业内部搭建npm镜像和私有npm仓库的开源方案。它同时解决了现有npm架构的一些问题。
830 0
使用cnpm搭建企业内部私有NPM仓库
|
JavaScript 前端开发 数据安全/隐私保护
Vue封装组件并发布到npm仓库
前言 使用Vue框架进行开发,组件封装是一个很常规的操作。一个封装好的组件可以在项目的任意地方使用,甚至我们可以直接从npm仓库下载别人封装好的组件来进行使用,比如iview、element-ui这一类的组件库。但是每个公司的业务场景可能不同,开发人员还是得必须封装自己得组件,如果换了一个项目,那么我们就只能复制组件代码到新的项目里面去了,这样稍显麻烦,其实我们可以将组建上传到npm仓库,要用的时候可以直接从npm安装使用。 总结下来有两点好处: 方面使用,任何项目无缝衔接。 可作为开源项目,积累经验。
615 0
Vue封装组件并发布到npm仓库
|
11月前
|
Linux 开发工具 git
Linux系统使用Git仓库安装Nvm工具并安装Npm和Node
Linux系统使用Git仓库安装Nvm工具并安装Npm和Node
337 0
|
11月前
|
JavaScript 前端开发 开发工具
前端工程化的Node.js之代码的组织/部署的包管理器 npm
在前端开发中,代码的组织和部署是非常重要的一环。为了提高开发效率和代码质量,我们需要使用工程化的方式来管理和组织代码。其中一个非常重要的前端工具就是 Node.js,而在 Node.js 中最为关键的工具之一就是包管理器 npm。
98 0
|
Linux 网络安全 开发工具
通过nexus3部署公司内部的私有npm仓库:从安装到配置、从发布包到测试包的一条龙服务
登录时使用默认用户admin,密码不知道就需要找默认的,点击Sign in时会提示你路径,这里我是这样查的,在linux服务器上输入以下命令
1501 0
|
JavaScript Shell API
|
资源调度 JavaScript
Vue实现一个全屏加载插件并发布至npm仓库
Vue实现一个全屏加载插件并发布至npm仓库
Vue实现一个全屏加载插件并发布至npm仓库
|
存储 缓存 Kubernetes
云原生大前端之使用 Helm 部署 Verdaccio,在 Kubernetes 上运行私有 NPM Registry
云原生大前端之使用 Helm 部署 Verdaccio,在 Kubernetes 上运行私有 NPM Registry
338 0
云原生大前端之使用 Helm 部署 Verdaccio,在 Kubernetes 上运行私有 NPM Registry

热门文章

最新文章

推荐镜像

更多