Skip to content

Commit a92cea2

Browse files
committed
Reinstall configured Node when npm is missing
1 parent 1facde3 commit a92cea2

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

build-dist.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GREEN='\033[0;32m'
77
BLUE='\033[0;34m'
88
NC='\033[0m'
99

10-
VERSION="1.4.3"
10+
VERSION="1.4.4"
1111
DIST_DIR="dist"
1212
ARCHIVE_NAME="shipnode-payload.tar.gz"
1313
INSTALLER_NAME="shipnode-installer.sh"
@@ -90,7 +90,7 @@ YELLOW='\033[1;33m'
9090
BLUE='\033[0;34m'
9191
NC='\033[0m'
9292
93-
VERSION="1.4.3"
93+
VERSION="1.4.4"
9494
INSTALL_DIR="$HOME/.shipnode"
9595
9696
# Parse flags

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BLUE='\033[0;34m'
1010
NC='\033[0m'
1111

1212
echo -e "${BLUE}╔════════════════════════════════════╗${NC}"
13-
echo -e "${BLUE}║ ShipNode Installer v1.4.3${NC}"
13+
echo -e "${BLUE}║ ShipNode Installer v1.4.4${NC}"
1414
echo -e "${BLUE}╚════════════════════════════════════╝${NC}"
1515
echo
1616

lib/commands/setup.sh

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,32 @@ cmd_setup() {
4646
echo "jq already installed: $(jq --version)"
4747
fi
4848
49-
# Install Node.js (using NodeSource)
49+
install_node=false
5050
if ! command -v node &> /dev/null; then
51-
echo "Installing Node.js $NODE_VERSION..."
51+
install_node=true
52+
else
53+
CURRENT_NODE_MAJOR=$(node --version | sed -E 's/^v([0-9]+).*/\1/')
54+
if [ "$CURRENT_NODE_MAJOR" != "$NODE_VERSION" ]; then
55+
echo "Node.js $(node --version) found, but v$NODE_VERSION.x is configured."
56+
install_node=true
57+
elif ! command -v npm &> /dev/null; then
58+
echo "Node.js $(node --version) found, but npm is missing."
59+
install_node=true
60+
else
61+
echo "Node.js already installed: $(node --version)"
62+
fi
63+
fi
64+
65+
# Install Node.js (using NodeSource)
66+
if [ "$install_node" = true ]; then
67+
echo "Installing Node.js $NODE_VERSION.x..."
5268
curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | $SUDO bash -
5369
$SUDO apt-get install -y nodejs
54-
else
55-
echo "Node.js already installed: $(node --version)"
70+
fi
71+
72+
if ! command -v npm &> /dev/null; then
73+
echo "Error: npm is required but was not installed"
74+
exit 1
5675
fi
5776
5877
# Install PM2

lib/core.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BLUE='\033[0;34m'
1010
NC='\033[0m' # No Color
1111

1212
# ShipNode version
13-
VERSION="1.4.3"
13+
VERSION="1.4.4"
1414

1515
# SSH multiplexing for connection reuse
1616
SSH_CONTROL_PATH="/tmp/shipnode-ssh-%r@%h:%p"

0 commit comments

Comments
 (0)