Skip to content

Commit 1314c01

Browse files
committed
Extract postinstall into script
1 parent c07328c commit 1314c01

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

apps/code/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"test": "vitest run",
2626
"test:e2e": "playwright test --config=tests/e2e/playwright.config.ts",
2727
"test:e2e:headed": "playwright test --config=tests/e2e/playwright.config.ts --headed",
28-
"postinstall": "cd ../.. && npx @electron/rebuild -f -m node_modules/node-pty && npx @electron/rebuild -f -m node_modules/better-sqlite3 || true && bash apps/code/scripts/patch-electron-name.sh && node apps/code/scripts/download-binaries.mjs",
28+
"postinstall": "bash scripts/postinstall.sh",
2929
"storybook": "storybook dev -p 6006",
3030
"build-storybook": "storybook build",
3131
"clean": "rm -rf .vite .turbo out node_modules/.vite",

apps/code/scripts/postinstall.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Postinstall script for the Electron app
4+
# Rebuilds native modules against Electron's Node headers and applies patches
5+
6+
set -e
7+
8+
REPO_ROOT="$(cd ../.. && pwd)"
9+
SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"
10+
11+
echo "Rebuilding native modules for Electron..."
12+
13+
cd "$REPO_ROOT"
14+
npx @electron/rebuild -f -m node_modules/node-pty
15+
npx @electron/rebuild -f -m node_modules/better-sqlite3 || true
16+
17+
echo "Patching Electron app name..."
18+
bash "$SCRIPTS_DIR/patch-electron-name.sh"
19+
20+
echo "Downloading binaries..."
21+
node "$SCRIPTS_DIR/download-binaries.mjs"
22+
23+
echo "Postinstall complete."

docs/TROUBLESHOOTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,31 @@ cd apps/code && npx electron-rebuild -f
110110

111111
Then restart the app.
112112

113+
## node-gyp failed to rebuild @parcel/watcher
114+
115+
If you see this error after pulling or switching branches:
116+
117+
```
118+
Error: node-gyp failed to rebuild '/path/to/node_modules/@parcel/watcher'
119+
```
120+
121+
`@parcel/watcher` ships prebuilt N-API binaries per platform (e.g. `@parcel/watcher-darwin-arm64`) and should not need recompilation. This error usually means a stale or partial install state is triggering a source rebuild that fails.
122+
123+
### Fix
124+
125+
```bash
126+
rm -rf node_modules/@parcel/watcher
127+
pnpm install
128+
```
129+
130+
If that doesn't work, nuke and reinstall:
131+
132+
```bash
133+
rm -rf node_modules && pnpm install
134+
```
135+
136+
Do **not** run `npx @electron/rebuild` against `@parcel/watcher` — it doesn't need it and the rebuild will fail.
137+
113138
## `pnpm i` shows "Packages: -198"
114139

115140
You might see something like this every time you run `pnpm install`:

0 commit comments

Comments
 (0)