Skip to content

Commit a5b9171

Browse files
AndyMik90claude
andauthored
fix(ci): handle npm workspaces partial node_modules (#1404)
* hotfix(build): disable npmRebuild for electron-builder workspace compatibility electron-builder's @electron/rebuild cannot properly handle symlinked node_modules directories in npm workspace setups. It fails with: ENOENT: no such file or directory, stat 'apps/frontend/node_modules' Setting npmRebuild: false bypasses this issue because: 1. stageRuntimePackages() already copies @lydell/node-pty to out/main/node_modules 2. @lydell/node-pty uses prebuilt binaries - no rebuild needed 3. This skips the problematic @electron/rebuild phase entirely Fixes macOS Intel, macOS Silicon, and potentially Windows release builds. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ci): handle npm workspaces partial node_modules blocking symlink npm workspaces may create a partial node_modules directory in apps/frontend for packages that couldn't be hoisted. This blocked the symlink creation because the condition checked if the directory existed before creating the symlink. Changes: - Remove any existing partial node_modules directory (not symlink) - Only then create the symlink to root node_modules - Add verification that symlink resolves correctly - Add detailed logging for debugging This fixes macOS release builds failing with ENOENT during @electron/osx-sign code signing phase. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9d6ac6f commit a5b9171

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

‎.github/actions/setup-node-frontend/action.yml‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,24 @@ runs:
5555
# With npm workspaces, packages are hoisted to root. Create a link so electron-builder
5656
# can find the modules during packaging and code signing.
5757
# Uses symlink on Unix, directory junction on Windows (works without admin privileges).
58+
#
59+
# IMPORTANT: npm workspaces may create a partial node_modules in apps/frontend for
60+
# packages that couldn't be hoisted. We must remove it and create a proper link to root.
5861
run: |
5962
# Verify npm ci succeeded
6063
if [ ! -d "node_modules" ]; then
6164
echo "::error::Root node_modules does not exist. npm ci may have failed."
6265
exit 1
6366
fi
6467
65-
# Create link if needed
66-
if [ ! -d "apps/frontend/node_modules" ] && [ ! -L "apps/frontend/node_modules" ]; then
68+
# Remove any existing node_modules in apps/frontend (npm workspaces may create partial one)
69+
if [ -d "apps/frontend/node_modules" ] && [ ! -L "apps/frontend/node_modules" ]; then
70+
echo "Removing partial node_modules created by npm workspaces..."
71+
rm -rf "apps/frontend/node_modules"
72+
fi
73+
74+
# Create link if it doesn't exist
75+
if [ ! -L "apps/frontend/node_modules" ]; then
6776
if [ "$RUNNER_OS" == "Windows" ]; then
6877
# Use directory junction on Windows (works without admin privileges)
6978
cmd //c "mklink /J apps\\frontend\\node_modules ..\\..\\node_modules"
@@ -83,5 +92,18 @@ runs:
8392
fi
8493
fi
8594
else
86-
echo "apps/frontend/node_modules already exists, skipping"
95+
echo "apps/frontend/node_modules symlink already exists"
96+
fi
97+
98+
# Verify the link works
99+
if [ -L "apps/frontend/node_modules" ]; then
100+
target=$(readlink apps/frontend/node_modules 2>/dev/null || echo "junction")
101+
echo "Verified: apps/frontend/node_modules -> $target"
102+
# Check that the target resolves correctly
103+
if [ -d "apps/frontend/node_modules" ]; then
104+
count=$(ls apps/frontend/node_modules 2>/dev/null | wc -l)
105+
echo "Link resolves to directory with $count entries"
106+
else
107+
echo "::warning::Link exists but does not resolve to a valid directory"
108+
fi
87109
fi

0 commit comments

Comments
 (0)