From 0c6b30cfa705c1d2f2ccd084cd76174738a7fb4b Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Tue, 29 Sep 2026 15:58:45 +0800 Subject: [PATCH] fix(docs): spawn nested npm through Node on Windows --- website-docs/scripts/build-site.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website-docs/scripts/build-site.mjs b/website-docs/scripts/build-site.mjs index 73734fb9..d81caee7 100644 --- a/website-docs/scripts/build-site.mjs +++ b/website-docs/scripts/build-site.mjs @@ -4,7 +4,10 @@ import { resolve, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); function run(dir, script) { - const result = spawnSync('npm', ['run', script], { cwd: resolve(root, dir), stdio: 'inherit' }); + const npmCLI = process.env.npm_execpath; + if (!npmCLI) throw new Error('Run the site build through npm so npm_execpath is available.'); + const result = spawnSync(process.execPath, [npmCLI, 'run', script], { cwd: resolve(root, dir), stdio: 'inherit' }); + if (result.error) throw new Error(`Could not run npm ${script}: ${result.error.message}`); if (result.status !== 0) process.exit(result.status || 1); } for (const dir of ['homepage', '.']) {