Skip to content

Commit 99cfbd3

Browse files
committed
fix: install extension npm dependencies during deploy
Extensions with a package.json (e.g. kernel/) had their node_modules excluded from the copy but never installed on the target. This caused 'Cannot find module' errors at runtime. After copying extensions, deploy now iterates directories with a package.json and runs npm install as the agent user using the resolved embedded runtime.
1 parent 400754b commit 99cfbd3

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

bin/deploy.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ source "$SCRIPT_DIR/lib/paths-common.sh"
2626
source "$SCRIPT_DIR/lib/json-common.sh"
2727
# shellcheck source=bin/lib/deploy-common.sh
2828
source "$SCRIPT_DIR/lib/deploy-common.sh"
29+
# shellcheck source=bin/lib/runtime-node.sh
30+
source "$SCRIPT_DIR/lib/runtime-node.sh"
2931
bb_enable_strict_mode
3032
bb_init_paths
3133

@@ -216,6 +218,29 @@ for ext in "$EXT_SRC"/*; do
216218
fi
217219
done
218220

221+
# Install extension dependencies (extensions with package.json)
222+
if [ "$DRY_RUN" -eq 0 ]; then
223+
npm_bin=""
224+
node_bin_dir="$(bb_resolve_runtime_node_bin_dir "$BAUDBOT_HOME" 2>/dev/null || true)"
225+
if [ -n "$node_bin_dir" ] && [ -x "$node_bin_dir/npm" ]; then
226+
npm_bin="$node_bin_dir/npm"
227+
fi
228+
229+
if [ -n "$npm_bin" ]; then
230+
for ext_dir in "$EXT_DEST"/*/; do
231+
[ -d "$ext_dir" ] || continue
232+
[ -f "$ext_dir/package.json" ] || continue
233+
ext_name="$(basename "$ext_dir")"
234+
log "installing dependencies for $ext_name/"
235+
if as_agent bash -c "cd '$ext_dir' && '$npm_bin' install --omit=dev 2>&1"; then
236+
log "$ext_name/ dependencies installed"
237+
else
238+
bb_log "⚠️ failed to install dependencies for $ext_name/ — extension may not load"
239+
fi
240+
done
241+
fi
242+
fi
243+
219244
# ── Skills ───────────────────────────────────────────────────────────────────
220245

221246
echo "Deploying skills..."

0 commit comments

Comments
 (0)