Skip to content

Commit 9c06c62

Browse files
Giu PlataniaGiu Platania
authored andcommitted
npm auto installer added
1 parent 4d6b6b1 commit 9c06c62

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

TASK.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# TASKS
2-
- 2026-03-01: DONE. Add a remote launcher script that installs the backend from local source and starts the API plus UI.
2+
- 2026-03-01: DONE. Add a remote launcher script that installs the backend from local source, installs npm when needed, and starts the API plus UI.
33
- 2026-03-01: DONE. Add remote access documentation for LAN and public IP RCH deployments.
44
- 2026-02-26: DONE. Add LXMF outbound delivery acknowledgement handling and log recipient delivery confirmations to the event feed.
55
- 2026-02-26: DONE. Abort gateway startup when API host/port is already bound to prevent duplicate hub instances and ratchet contention.

run_server_ui_remote.sh

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,52 @@ resolve_public_host() {
2525
printf '127.0.0.1\n'
2626
}
2727

28+
ensure_npm() {
29+
local current_uid
30+
local -a elevate=()
31+
32+
if command -v npm >/dev/null 2>&1; then
33+
return
34+
fi
35+
36+
echo "npm was not found in PATH. Attempting to install Node.js and npm..."
37+
38+
current_uid="${EUID:-$(id -u)}"
39+
if [[ "$current_uid" -ne 0 ]]; then
40+
if command -v sudo >/dev/null 2>&1; then
41+
elevate=(sudo)
42+
else
43+
echo "npm is missing and this script needs root privileges to install it." >&2
44+
echo "Install Node.js/npm manually or rerun this script with sudo." >&2
45+
exit 1
46+
fi
47+
fi
48+
49+
if command -v apt-get >/dev/null 2>&1; then
50+
"${elevate[@]}" apt-get update
51+
"${elevate[@]}" apt-get install -y nodejs npm
52+
elif command -v dnf >/dev/null 2>&1; then
53+
"${elevate[@]}" dnf install -y nodejs npm
54+
elif command -v yum >/dev/null 2>&1; then
55+
"${elevate[@]}" yum install -y nodejs npm
56+
elif command -v apk >/dev/null 2>&1; then
57+
"${elevate[@]}" apk add --no-cache nodejs npm
58+
elif command -v pacman >/dev/null 2>&1; then
59+
"${elevate[@]}" pacman -Sy --noconfirm nodejs npm
60+
elif command -v zypper >/dev/null 2>&1; then
61+
"${elevate[@]}" zypper --non-interactive install nodejs npm
62+
else
63+
echo "Could not auto-install npm: no supported package manager was found." >&2
64+
echo "Install Node.js 20 LTS and npm manually, then rerun this script." >&2
65+
exit 1
66+
fi
67+
68+
if ! command -v npm >/dev/null 2>&1; then
69+
echo "npm is still unavailable after the install attempt." >&2
70+
exit 1
71+
fi
72+
}
73+
2874
VENV_DIR="${VENV_DIR:-.venv}"
2975
RTH_STORAGE_DIR="${RTH_STORAGE_DIR:-RTH_Store}"
3076
RTH_HUB_MODE="${RTH_HUB_MODE:-embedded}"
@@ -93,10 +139,7 @@ if ! "$PYTHON_EXE" -c "import websockets" >/dev/null 2>&1; then
93139
"$PYTHON_EXE" -m pip install "websockets>=12,<14"
94140
fi
95141

96-
if ! command -v npm >/dev/null 2>&1; then
97-
echo "npm is required (Node.js 20 LTS recommended) but was not found in PATH." >&2
98-
exit 1
99-
fi
142+
ensure_npm
100143

101144
if [[ ! -d "ui/node_modules" ]]; then
102145
echo "Installing UI dependencies..."

0 commit comments

Comments
 (0)