代理服务器 查看npm_使用sinopia搭建npm仓库,代理内网服务器npm服务

在window环境下需要安装npm install --global --production windows-build-tools

npm install -g node-gyp

安装sinopianpm install -g sinopia

配置监听端口及ip

你需要去配置下 .config/sinopia/config.yaml文件,这个文件你需要去找一下。

在文件末尾添加(端口号自行设定):

listen: 0.0.0.0:4873

然后就可以访问虚拟机的npm仓库地址了

服务端启动sinopiasinopia

linux后台启动

node服务非常脆弱,一般在实际中使用都会配合守护进程。这里我用的是 pm2 做守护进程

首先全局安装 PM2,执行下面语句:npm install -g pm2

再执行下面语句,通过 PM2 启动 sinopia:pm2 start `which sinopia`

客户端配置仓库地址

ip需要更改为仓库地址npm set registry http://172.0.0.5:4873/

然后客户端就可以从代理服务器下载npm包了npm install -g forever

npm install -g node-gyp

nrm 来管理 npm 的镜像地址

添加镜像地址nrm add 94

nrm add taobao https://registry.npm.taobao.org

nrm add npm https://registry.npmjs.org

切换镜像地址nrm use taobao

测试镜像地址nrm test taobao

其他命令ls                           List all the registries

current                      Show current registry name

use                Change registry to registry

add   [home]  Add one custom registry

del                Delete one custom registry

home  [browser]    Open the homepage of registry with optional browser

test [registry]              Show response time for specific or all registries

help                         Print this help

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值