fix: pin yarn registry and package manager

This commit is contained in:
Haitao Pan 2026-03-19 23:46:35 +08:00
parent bf071a2679
commit b7dafdd508
4 changed files with 9 additions and 9 deletions

1
.yarnrc Normal file
View File

@ -0,0 +1 @@
registry "https://registry.npmjs.org"

View File

@ -4,7 +4,7 @@ enableGlobalCache: false
nodeLinker: node-modules nodeLinker: node-modules
npmRegistryServer: "https://registry.npmmirror.com" npmRegistryServer: "https://registry.npmjs.org"
packageExtensions: packageExtensions:
"next-contentlayer@*": "next-contentlayer@*":

View File

@ -49,7 +49,6 @@ init:
echo "❌ Unsupported OS. Please install Yarn manually."; exit 1; \ echo "❌ Unsupported OS. Please install Yarn manually."; exit 1; \
fi; \ fi; \
fi fi
yarn config set npmRegistryServer https://registry.npmmirror.com
yarn install --immutable yarn install --immutable
ensure-deps: ensure-deps:
@ -83,7 +82,6 @@ test:
@yarn test || echo "No tests configured" @yarn test || echo "No tests configured"
build: init build: init
yarn config set npmRegistryServer https://registry.npmmirror.com
@if [ -z "$(SKIP_SYNC)" ]; then \ @if [ -z "$(SKIP_SYNC)" ]; then \
$(MAKE) sync-dl-index; \ $(MAKE) sync-dl-index; \
fi fi

View File

@ -8,12 +8,13 @@ cd /var/www/XControl/dashboard
# 2. 安装 Node.js 和 npm # 2. 安装 Node.js 和 npm
sudo apt install -y nodejs sudo apt install -y nodejs
# 安装生产依赖(跳过 devDependencies # 使用仓库声明的 Yarn 版本和 npm 官方 registry避免落到全局 Yarn Classic 或 yarnpkg proxy。
npm install --omit=dev --registry=https://registry.npmmirror.com corepack enable
npm install -g yarn --registry=https://registry.npmmirror.com corepack prepare yarn@4.12.0 --activate
yarn install --immutable
# 构建项目 # 构建项目
/usr/bin/npm run build --registry=https://registry.npmmirror.com yarn build
# 启动 Next.js 生产服务器 # 启动 Next.js 生产服务器
/usr/bin/npm start yarn start