本地npm缓存仓库搭建

本地npm缓存仓库搭建

安装组件
npm install -global verdaccio
# or
yarn global add verdaccio
启动

默认启动,端口4873
$ verdaccio

指定端口启动
$ verdaccio --listen 8888

启动成功

PS C:\Users\admin> verdaccio --listen 8888
 info --- Creating default config file in C:\Users\admin\AppData\Roaming\verdaccio\config.yaml  
 warn --- config file  - C:\Users\admin\AppData\Roaming\verdaccio\config.yaml # 配置文件路径
 warn --- Plugin successfully loaded: verdaccio-htpasswd
 warn --- Plugin successfully loaded: verdaccio-audit
 warn --- http address - http://localhost:8888/ - verdaccio/5.4.0  # web访问地址

命令工具
verdaccio --listen 4000 --config ~./config.yaml

Command Default Example Description
–listen \ -l 4873 -p 7000 http port
–config \ -c ~/.local/verdaccio/config.yaml ~./config.yaml the configuration file
–info \ -i prints local environment information
配置

配置文件路径:
windows默认
C:\Users\<用户名>\AppData\Roaming\verdaccio\config.yaml
更改默认镜像地址为淘宝地址


# path to a directory with all packages
storage: ./storage  # 仓库缓存路径,可根据需要自行修改

# a list of other known repositories we can talk to
uplinks:
  npmjs:
    url: https://registry.npmjs.org/  # 更改为 https://registry.npm.taobao.org/

npm地址修改:

npm set registry http://localhost:4873/
# or
yarn config set registry http://localhost:4873/
配置为windows服务
  1. 创建文件夹
    • mkdir c:\verdaccio
    • cd c:\verdaccio
  2. 局部安装verdaccio
    • npm install verdaccio
  3. 拷贝配置文件config.yaml到本地:c:\verdaccio\config.yaml
  4. 下载nssm
    • 下载地址:https://www.nssm.cc/download/
    • 安装服务,nssm install []
    • 参数配置
* Path: `node`
* Startup directory: `c:\verdaccio`
* Arguments: `c:\verdaccio\node_modules\verdaccio\build\lib\cli.js -c c:\verdaccio\config.yaml`

You can adjust other service settings under other tabs as desired. When you are done, click Install service button

完成后查看windows服务,可通过服务单独管理verdaccio

你可能感兴趣的:(配置管理,npm,缓存,前端)