From b7dafdd508587e1bde66f7a0c9609925b5072b67 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Thu, 19 Mar 2026 23:46:35 +0800 Subject: [PATCH] fix: pin yarn registry and package manager --- .yarnrc | 1 + .yarnrc.yml | 2 +- Makefile | 2 -- start.sh | 13 +++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 .yarnrc diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 0000000..142dad8 --- /dev/null +++ b/.yarnrc @@ -0,0 +1 @@ +registry "https://registry.npmjs.org" diff --git a/.yarnrc.yml b/.yarnrc.yml index 9e9e742..d4c4fe4 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -4,7 +4,7 @@ enableGlobalCache: false nodeLinker: node-modules -npmRegistryServer: "https://registry.npmmirror.com" +npmRegistryServer: "https://registry.npmjs.org" packageExtensions: "next-contentlayer@*": diff --git a/Makefile b/Makefile index bfdd825..da43fee 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,6 @@ init: echo "❌ Unsupported OS. Please install Yarn manually."; exit 1; \ fi; \ fi - yarn config set npmRegistryServer https://registry.npmmirror.com yarn install --immutable ensure-deps: @@ -83,7 +82,6 @@ test: @yarn test || echo "No tests configured" build: init - yarn config set npmRegistryServer https://registry.npmmirror.com @if [ -z "$(SKIP_SYNC)" ]; then \ $(MAKE) sync-dl-index; \ fi diff --git a/start.sh b/start.sh index 13acfd3..3039dfb 100755 --- a/start.sh +++ b/start.sh @@ -8,12 +8,13 @@ cd /var/www/XControl/dashboard # 2. 安装 Node.js 和 npm sudo apt install -y nodejs -# 安装生产依赖(跳过 devDependencies) -npm install --omit=dev --registry=https://registry.npmmirror.com -npm install -g yarn --registry=https://registry.npmmirror.com +# 使用仓库声明的 Yarn 版本和 npm 官方 registry,避免落到全局 Yarn Classic 或 yarnpkg proxy。 +corepack enable +corepack prepare yarn@4.12.0 --activate +yarn install --immutable + # 构建项目 -/usr/bin/npm run build --registry=https://registry.npmmirror.com +yarn build # 启动 Next.js 生产服务器 -/usr/bin/npm start - +yarn start