From 44bfd8350ec52803a33b5351f0a5fbf2b7a88b9f Mon Sep 17 00:00:00 2001 From: renxia Date: Tue, 10 Dec 2024 15:57:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20npm=20=E7=A7=81?= =?UTF-8?q?=E6=9C=89=E4=BB=93=E5=BA=93=E9=85=8D=E7=BD=AE=E4=B8=BA=20http?= =?UTF-8?q?=20=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/utils/npm.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/utils/npm.js b/modules/utils/npm.js index 21f4514d..631c1758 100644 --- a/modules/utils/npm.js +++ b/modules/utils/npm.js @@ -1,5 +1,6 @@ import url from 'url'; import https from 'https'; +import http from 'http'; import gunzip from 'gunzip-maybe'; import { LRUCache } from 'lru-cache'; @@ -37,7 +38,12 @@ const notFound = ''; function get(options) { return new Promise((accept, reject) => { - https.get(options, accept).on('error', reject); + if (npmRegistryURL.startsWith('http://')) { + delete options.agent; + http.get(options, accept).on('error', reject); + } else { + https.get(options, accept).on('error', reject); + } }); }