From 729d725baf5e9903fc24b03b5f9f59c1f598b658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E7=91=BE?= Date: Sun, 15 Sep 2024 21:40:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=9F=E6=88=90.npmrc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/init/config.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/core/init/config.ts b/src/core/init/config.ts index a636179..0eb7d13 100644 --- a/src/core/init/config.ts +++ b/src/core/init/config.ts @@ -186,6 +186,23 @@ export class KarinCfgInit { console.log('检测到已安装pm2~') } + /** 检查是否为官方源 如果不是则生成.npmrc */ + const registry = await this.shell('npm config get registry') + if (registry !== 'https://registry.npmjs.org/') { + const text = `node_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/sqlite3 +better_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3 +sass_binary_site=https://registry.npmmirror.com/-/binary/node-sass +sharp_binary_host=https://registry.npmmirror.com/-/binary/sharp +sharp_libvips_binary_host=https://registry.npmmirror.com/-/binary/sharp-libvips +canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas +# 19以下版本 +puppeteer_download_host=https://registry.npmmirror.com/mirrors +# 20以上版本 +PUPPETEER_DOWNLOAD_BASE_URL = https://registry.npmmirror.com/binaries/chrome-for-testing` + + fs.writeFileSync('.npmrc', text) + } + console.log('依赖环境初始化完成~') }