在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