1. 反向代理上游仓库
nginx配置如下:
1 | location / { |
2. 设置pnpm的仓库源
修改仓库源的地址
1 | $ pnpm config set registry https://your.domian.com |
测试一下
1 | $ pnpm info react |
此时pnpm能够获取到包信息,但由于实际安装时是从.tarball中获取包的实际下载地址,还需要对结果进一步处理
3. 修改info的响应信息
nginx需要启用ngx_http_sub_module模块,使用nginx -V查看是否启用–with-http_sub_module
1 | $ nginx -V |
修改配置如下:
1 | location / { |
再次测试下,可以看到.tarball的地址被替换为https://your.domian.com/
1 | $ pnpm info react |