fix(dev): make npm run dev work on Windows (#374)

spawnSync('npm') without a shell fails with ENOENT on Windows because npm is npm.cmd, not npm.exe. The root dev script also used Unix VAR=value prefixes, which cmd.exe rejects.

Use shell: true when spawning npm on Windows, and set renderer URLs with cross-env.
This commit is contained in:
Hanlin
2026-09-14 19:04:22 +08:00
committed by GitHub
parent ed2bb86536
commit e064f3ad68
3 changed files with 74 additions and 38 deletions
+10 -1
View File
@@ -40,7 +40,16 @@ const stale = APPS.filter((app) => {
if (stale.length) {
console.log(`Rebuilding stale preloads: ${stale.join(', ')}`)
for (const app of stale) {
const r = spawnSync('npm', ['run', 'build', '-w', `@genoffice/${app}`], { stdio: 'inherit' })
const r = spawnSync('npm', ['run', 'build', '-w', `@genoffice/${app}`], {
stdio: 'inherit',
// Windows has npm.cmd / npm.ps1, not npm.exe; spawn without a shell
// looks up npm.exe only and fails with ENOENT.
shell: process.platform === 'win32',
})
if (r.error) {
console.error(r.error)
process.exit(1)
}
if (r.status !== 0) process.exit(r.status ?? 1)
}
}