From bfe9e47db17da07f649b6aab115b4e2d4538f9a7 Mon Sep 17 00:00:00 2001 From: locpham Date: Sat, 8 Aug 2026 14:19:03 +0000 Subject: [PATCH] FIX (lan 2): build_windows.ps1 tu cai @babel/standalone neu thieu (ERR_MODULE_NOT_FOUND) --- build_windows.ps1 | 10 ++++++++++ wiki.md | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/build_windows.ps1 b/build_windows.ps1 index edadc1e..c4789ab 100644 --- a/build_windows.ps1 +++ b/build_windows.ps1 @@ -11,6 +11,16 @@ python -m pip install -r requirements.txt pyinstaller pywin32 Write-Host "== [2/6] Frontend bundle (app.jsx -> app.precompiled.js) ==" npm install +# Dam bao @babel/standalone co (build.mjs import truc tiep - da gap +# ERR_MODULE_NOT_FOUND tren may Windows khi package.json cu thieu dep). +if (-not (Test-Path "node_modules\@babel\standalone")) { + Write-Host "Thieu @babel/standalone - dang cai them..." + npm install @babel/standalone --no-audit --no-fund +} +if (-not (Test-Path "node_modules\@babel\standalone")) { + Write-Host "ERROR: Khong cai duoc @babel/standalone. Kiem tra ket noi npm!" -ForegroundColor Red + exit 1 +} node build.mjs # @babel/standalone; thay cho 'npm run build' (Babel 8 ESM-only CLI conflict) Write-Host "== [3/6] Build daw_engine.exe (PyInstaller) ==" diff --git a/wiki.md b/wiki.md index 234aab4..4b75764 100644 --- a/wiki.md +++ b/wiki.md @@ -1,3 +1,9 @@ +### [2026-08-08] FIX (lan 2): ERR_MODULE_NOT_FOUND '@babel/standalone' vẫn xảy ra — build_windows.ps1 TỰ cài dep nếu thiếu +- **Tóm tắt thay đổi:** User vẫn gặp ERR_MODULE_NOT_FOUND '@babel/standalone' dù đã thêm vào package.json — máy Windows chưa pull package.json mới hoặc npm install chưa cài. Fix: `build_windows.ps1` bước [2/6] — sau `npm install`, TỰ KIỂM TRA `node_modules\@babel\standalone`; thiếu → `npm install @babel/standalone --no-audit --no-fund`; vẫn thiếu → ERROR + exit 1. Không còn phụ thuộc package.json mới trên máy user. +- **Các file ảnh hưởng:** `build_windows.ps1` (bước 2 tự cài @babel/standalone) +- **Ghi chú/Test (nếu có):** File ASCII-only + UTF-8 BOM (không lặp lỗi PS5.1), brace depth 0. User: pull build_windows.ps1 mới (hoặc toàn bộ) rồi chạy lại. + +--- ### [2026-08-08] FIX: build.mjs ERR_MODULE_NOT_FOUND '@babel/standalone' trên Windows — package.json thiếu dependency - **Tóm tắt thay đổi:** User chạy build_windows.ps1 (bước 2/6 node build.mjs) nhận `Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@babel/standalone' imported from build.mjs`. Root cause: `build.mjs` import `@babel/standalone` nhưng **package.json KHÔNG khai báo** dependency này (máy dev có sẵn trong node_modules từ trước nên không lộ; máy Windows `npm install` chỉ cài theo package.json → thiếu). Fix: thêm `"@babel/standalone": "^7.29.8"` vào dependencies + chạy `npm install` cập nhật `package-lock.json`. - **Các file ảnh hưởng:** `package.json` (+@babel/standalone), `package-lock.json` (npm install)